Exemple #1
0
 public async Task Execute(string email, string subject, string body)
 {
     _mailJetSettings = _configuration.GetSection("MailJet").Get <MailJetSettings>();
     MailjetClient client = new MailjetClient(_mailJetSettings.ApiKey, _mailJetSettings.SecretKey)
     {
         Version = ApiVersion.V3_1,
     };
     MailjetRequest request = new MailjetRequest {
         Resource = Send.Resource,
     }
     .Property(Send.Messages, new JArray {
         new JObject {
             {
                 "From",
                 new JObject {
                     { "Email", "*****@*****.**" },
                     { "Name", "Chris" }
                 }
             }, {
                 "To",
                 new JArray {
                     new JObject {
                         {
                             "Email",
                             "*****@*****.**"
                         }, {
                             "Name",
                             "Chris"
                         }
                     }
                 }
             }, {
                 "Subject",
                 subject
             }, {
                 "TextPart",
                 "My first Mailjet email"
             }, {
                 "HTMLPart",
                 body
             }
         }
     });
     await client.PostAsync(request);
 }
Exemple #2
0
        public async Task Execute(string email, string subject, string body)
        {
            _mailJetSettings = _configuration.GetSection("MailJet").Get <MailJetSettings>();

            MailjetClient client = new MailjetClient(_mailJetSettings.ApiKey, _mailJetSettings.SecretKey)
            {
                //Version = ApiVersion.V3_1,
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    {
                        "From",
                        new JObject {
                            { "Email", "*****@*****.**" },
                            { "Name", "Akash" }
                        }
                    }, {
                        "To",
                        new JArray {
                            new JObject {
                                {
                                    "Email",
                                    email
                                }, {
                                    "Name",
                                    "Anamika"
                                }
                            }
                        }
                    }, {
                        "Subject",
                        subject
                    }, {
                        "HTMLPart",
                        body
                    }
                }
            });
            await client.PostAsync(request);
        }
Exemple #3
0
        public async Task Execute(string email, string subject, string body)
        {
            _mailJetSettings = _configuration.GetSection("MailJet").Get <MailJetSettings>();

            MailjetClient client = new MailjetClient(_mailJetSettings.ApiKey, _mailJetSettings.SecretKey)
            {
                //Version = ApiVersion.V3_1,
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    { "From", new JObject {
                          { "Email", WC.EmailFrom },
                          { "Name", "Manny" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", email },
                              { "Name", "DotNetMastery" }
                          }
                      } },
                    { "Subject", subject },
                    { "HTMLPart", body }
                }
            });
            //await client.PostAsync(request);
            MailjetResponse response = await client.PostAsync(request);

            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
            }
            else
            {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }
        }
Exemple #4
0
 public async Task Execute(string email, string subject, string body)
 {
     MailJetSettings = _configuration.GetSection("MailJet").Get <MailJetSettings>();
     MailjetClient client = new MailjetClient(MailJetSettings.ApiKey, MailJetSettings.SecretKey)
     {
         Version = ApiVersion.V3_1,
     };
     MailjetRequest request = new MailjetRequest
     {
         Resource = Send.Resource,
     }
     .Property(Send.Messages, new JArray {
         new JObject {
             {
                 "From",
                 new JObject {
                     { "Email", "*****@*****.**" },
                     { "Name", "Rocky App Admin" }
                 }
             }, {
                 "To",
                 new JArray {
                     new JObject {
                         {
                             "Email",
                             email
                         }, {
                             "Name",
                             "DotNetMastery"
                         }
                     }
                 }
             }, {
                 "Subject",
                 subject
             }, {
                 "HTMLPart",
                 body
             }
         }
     });
     MailjetResponse response = await client.PostAsync(request);
 }
Exemple #5
0
        public async Task Execute(string email, string subject, string body)
        {
            _mailJetSettings = _configuration.GetSection("MailJet").Get <MailJetSettings>();

            MailjetClient client = new MailjetClient(_mailJetSettings.ApiKey, _mailJetSettings.SecretKey)
            {
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.FromEmail, "*****@*****.**")
            .Property(Send.FromName, "protonmail")
            .Property(Send.Subject, subject)
            .Property(Send.HtmlPart, body)
            .Property(Send.Recipients, new JArray {
                new JObject {
                    { "Email", email }
                }
            });
            MailjetResponse response = await client.PostAsync(request);
        }
Exemple #6
0
        public async Task Execute(string email, string subject, string body)
        {
            _mailJetSettings = _configuration.GetSection("MailJet").Get <MailJetSettings>();

            var client = new MailjetClient(_mailJetSettings.ApiKey, _mailJetSettings.SecretKey);

            var request = new MailjetRequest {
                Resource = Send.Resource
            }
            .Property(Send.FromEmail, "*****@*****.**")
            .Property(Send.FromName, "From Alonso")
            .Property(Send.Subject, subject)
            .Property(Send.HtmlPart, body)
            .Property(Send.Recipients, new JArray
            {
                new JObject
                {
                    { "Email", email }
                }
            });

            await client.PostAsync(request);
        }