Ejemplo n.º 1
0
        private async Task <long> CreateTemplate()
        {
            // arrange
            var templateName = "C# integration test template " + DateTime.UtcNow;

            MailjetRequest request = new MailjetRequest
            {
                Resource = Template.Resource,
            }
            .Property(Template.Author, "Mailjet team")
            .Property(Template.Copyright, "Mailjet")
            .Property(Template.Description, "Used to send templated emails in C# SDK integration test")
            .Property(Template.EditMode, Template.EditModeValue_MJMLBuilder)
            .Property(Template.IsTextPartGenerationEnabled, true)
            .Property(Template.Locale, "en_US")
            .Property(Template.Name, templateName)
            .Property(Template.OwnerType, Template.OwnerTypeValue_Apikey)
            .Property(Template.Purposes, JArray.FromObject(new[] { "transactional" }));

            // act
            MailjetResponse response = await _client.PostAsync(request);

            // assert
            Assert.IsTrue(response.IsSuccessStatusCode);

            Assert.AreEqual(1, response.GetTotal());
            Assert.AreEqual(templateName, response.GetData().Single().Value <string>("Name"));

            long templateId = response.GetData().Single().Value <long>("ID");

            return(templateId);
        }
Ejemplo n.º 2
0
        ///
        /// This calls sends a message to one recipient with a CustomID
        ///
        //public ActionResult Index()
        //{
        //    return View();
        //}

        //public ActionResult SendEmail()
        //{
        //    //ExecuteTest().Wait();
        //    Execute(123);

        //    return View("MemberResponse");
        //}
        static async Task RunAsync()
        {
            string Blackjack_Public_Key  = WebConfigurationManager.AppSettings["apiPublicMJKey"];
            string Blackjack_Private_Key = WebConfigurationManager.AppSettings["apiPrivateMJKey"];

            MailjetClient  client  = new MailjetClient(Blackjack_Public_Key, Blackjack_Private_Key); //(Environment.GetEnvironmentVariable(Blackjack_Public_Key), Environment.GetEnvironmentVariable(Blackjack_Private_Key));
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource
            }
            .Property(Send.FromEmail, "*****@*****.**")
            .Property(Send.FromName, "Jonas Paskus")
            .Property(Send.Subject, "Your company's event outing!")
            .Property(Send.TextPart, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
            .Property(Send.HtmlPart, "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!")
            .Property(Send.To, new JArray {
                new JObject {
                    { "Email", "*****@*****.**" }
                }
            });
            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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }
        }
        public void TestSmsStatisticsAsync()
        {
            var expectedData = new JArray();
            var mockHttp     = new MockHttpMessageHandler();
            var jsonResponse = GenerateJsonResponse(1, 1, expectedData);

            // Setup a respond for the user api (including a wildcard in the URL)
            mockHttp.When("https://api.mailjet.com/v4/*")
            .Respond(JsonMediaType, jsonResponse);         // Respond with JSON

            IMailjetClient client = new MailjetClient(API_TOKEN, mockHttp)
            {
                Version = ApiVersion.V4
            };

            MailjetRequest request = new MailjetRequest
            {
                Resource = sms.SMS.Resource
            }
            .Filter(sms.SMS.FromTS, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString())
            .Filter(sms.SMS.ToTS, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());

            MailjetResponse response = client.GetAsync(request).Result;

            Assert.IsTrue(response.IsSuccessStatusCode);
            Assert.IsTrue(JToken.DeepEquals(expectedData, response.GetData()));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Createse a new Mailjet contact
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="apiSecret"></param>
        /// <param name="contactName"></param>
        /// <param name="contactEmail"></param>
        /// <returns></returns>
        public static async Task <int> CreateContactAsync(this IEmailSender emailSender, string apiKey, string apiSecret, string contactName, string contactEmail)
        {
            int           contactId = 0;
            MailjetClient client    = new MailjetClient(apiKey, apiSecret)
            {
                Version = ApiVersion.V3,
            };

            MailjetRequest request = new MailjetRequest
            {
                Resource = Contact.Resource,
            }
            .Property(Contact.IsExcludedFromCampaigns, "true")
            .Property(Contact.Name, contactName)
            .Property(Contact.Email, contactEmail);
            MailjetResponse response = await client.PostAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var responseData = response.GetData();
                List <ResponseClass> responseDataList = JsonConvert.DeserializeObject <List <ResponseClass> >(responseData.ToString());
                contactId = responseDataList.FirstOrDefault().ID;
            }

            return(contactId);
        }
Ejemplo n.º 5
0
        static public async System.Threading.Tasks.Task EnviarEmailAsync(string email, string nombre, DateTime horario, string peluquero)
        {
            var imagenHTML = @"<img src='http://friseur.azurewebsites.net/img/logo.png' style ='width:300px;height:300px;' > ";

            MailjetClient  client  = new MailjetClient("7ae7ed62b20c4df07110d474410769ae", "889c023b436e6922b67fd16ffa8fb1cc");
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.FromEmail, "*****@*****.**")
            .Property(Send.FromName, "Friseur Barber Shop")
            .Property(Send.Subject, "Gracias por sacar un turno con nostros!")
            .Property(Send.TextPart, "Hola " + nombre + "! Este es tu turno para cortate el pelo: " + horario.ToString())
            .Property(Send.HtmlPart, imagenHTML +
                      "<h3>Hola " + nombre + "!</h3><br />Este es tu turno para cortate el pelo: " + horario.ToString() + "<br /> Peluquero: " + peluquero)
            .Property(Send.To, nombre + " <" + email + ">");
            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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds an existing mailjet contact to a contact list
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="apiSecret"></param>
        /// <param name="contactId"></param>
        /// <param name="listId"></param>
        /// <returns></returns>
        public static async Task <long> AddContactToContactListAsync(this IEmailSender emailSender, string apiKey, string apiSecret, string contactId, string listId)
        {
            long          listRecipientId = 0;
            MailjetClient client          = new MailjetClient(apiKey, apiSecret)
            {
                Version = ApiVersion.V3,
            };

            MailjetRequest request = new MailjetRequest
            {
                Resource = Listrecipient.Resource,
            }
            .Property("ContactID", contactId)
            .Property("ListID", listId);
            MailjetResponse response = await client.PostAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var responseData = response.GetData();
                List <ResponseClass> responseDataList = JsonConvert.DeserializeObject <List <ResponseClass> >(responseData.ToString());
                listRecipientId = responseDataList.FirstOrDefault().ID;
            }

            return(listRecipientId);
        }
Ejemplo n.º 7
0
        public async Task SendEmail(string emailId, string firstName, string eventName, string action)
        {
            //MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
            // created object with required keys and add all other parameters
            MailjetClient  client  = new MailjetClient("2946db6b27a9f2d02583fd29e972553d", "3baa0be00212cb6193dd2c281122896e");
            MailjetRequest request = new MailjetRequest {
                Resource = Send.Resource,
            }
            .Property(Send.FromEmail, "*****@*****.**")
            .Property(Send.FromName, "TCSS 559 Group 9")
            .Property(Send.Subject, "Easy Events - Event Registration")
            .Property(Send.TextPart, "Registration Successfull")
            .Property(Send.HtmlPart, "<h3>Dear " + firstName + ", <br /> You have successfully " + action + " for event " + eventName + ".<br /> Thanks,<br />Easy Events Team")//body of email
            .Property(Send.Recipients, new JArray {
                new JObject {
                    { "Email", emailId }
                }
            });                                                                        //add receiver email
            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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }
        }
Ejemplo n.º 8
0
        private async Task FillTemplateContent(long templateId)
        {
            // arrange
            var content = File.ReadAllText(Path.Combine("Resources", "MJMLTemplate.mjml"));

            MailjetRequest request = new MailjetRequest
            {
                Resource   = TemplateDetailcontent.Resource,
                ResourceId = ResourceId.Numeric(templateId)
            }
            .Property(TemplateDetailcontent.MJMLContent, content)
            .Property(TemplateDetailcontent.Headers, JObject.FromObject(new Dictionary <string, string>()
            {
                { "Subject", "Test transactional template subject " + DateTime.UtcNow },
                { "SenderName", "Test transactional template" },
                { "SenderEmail", _senderEmail },
                { "From", _senderEmail },
            }));

            // act
            MailjetResponse response = await _client.PostAsync(request);

            // assert
            Assert.IsTrue(response.IsSuccessStatusCode);
            Assert.AreEqual(1, response.GetTotal());
            Assert.AreEqual(content, response.GetData().Single().Value <string>("MJMLContent"));
        }
Ejemplo n.º 9
0
        public static async Task <string> GetValidSenderEmail(MailjetClient client)
        {
            MailjetRequest request = new MailjetRequest
            {
                Resource = Sender.Resource
            };

            MailjetResponse response = await client.GetAsync(request);

            Assert.AreEqual(200, response.StatusCode);

            foreach (var emailObject in response.GetData())
            {
                if (emailObject.Type != JTokenType.Object)
                {
                    continue;
                }

                if (emailObject.Value <string>("Status") == "Active")
                {
                    return(emailObject.Value <string>("Email"));
                }
            }

            Assert.Fail("Cannot find Active sender address under given account");
            throw new AssertFailedException();
        }
        public void TestSmsExportAsync()
        {
            int    expectedCode        = 1;
            string expectedName        = "PENDING";
            string expectedDescription = "The request is accepted.";

            var status = new JObject
            {
                { Code, expectedCode },
                { Name, expectedName },
                { Description, expectedDescription }
            };

            var smsExportResponse = new JObject
            {
                { Status, status }
            };

            var mockHttp = new MockHttpMessageHandler();

            // Setup a respond for the user api (including a wildcard in the URL)
            mockHttp.When("https://api.mailjet.com/v4/*")
            .Respond(JsonMediaType, GenerateJsonResponse(smsExportResponse));         // Respond with JSON

            // timsestamp range offset
            int offset = 1000;

            IMailjetClient client = new MailjetClient(API_TOKEN, mockHttp)
            {
                Version = ApiVersion.V4
            };

            MailjetRequest request = new MailjetRequest
            {
                Resource = sms.Export.Resource
            }
            .Property(sms.Export.FromTS, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds())
            .Property(sms.Export.ToTS, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + offset);


            MailjetResponse response = client.PostAsync(request).Result;

            Assert.IsTrue(response.IsSuccessStatusCode);
            Assert.AreEqual(expectedCode, response.GetData()[0][Status].Value <int>(Code));
            Assert.AreEqual(expectedName, response.GetData()[0][Status].Value <string>(Name));
            Assert.AreEqual(expectedDescription, response.GetData()[0][Status].Value <string>(Description));
        }
Ejemplo n.º 11
0
        public static async Task <bool> SendEmail(Email email)
        {
            try
            {
                MailjetClient client = new MailjetClient(userId, userSecretKey)
                {
                    Version = ApiVersion.V3_1,
                };

                var request = CreateMailjetRequest(email);

                MailjetResponse response = null;

                try
                {
                    logger.Debug("{0} Отправка запроса на сервер Mailjet", GetThreadInfo());
                    response = await client.PostAsync(request);
                }
                catch (Exception ex)
                {
                    logger.Error("{1} Не удалось отправить письмо: \n{0}", ex, GetThreadInfo());
                    return(false);
                }

                MailjetMessage[] messages = response.GetData().ToObject <MailjetMessage[]>();

                logger.Debug("{1} Получен ответ: Code {0}", response.StatusCode, GetThreadInfo());

                if (response.IsSuccessStatusCode)
                {
                    logger.Debug(response.GetData());
                    return(true);
                }
                else
                {
                    logger.Debug(response.GetData());
                    logger.Debug("{1} ErrorMessage: {0}\n", response.GetErrorMessage(), GetThreadInfo());
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "При обработке ответа на отправку письма возникла ошибка.\n");
            }
            return(false);
        }
Ejemplo n.º 12
0
        public static async Task GenerateClient(string publicKey, string privateKey)
        {
            Mailjet.Client.MailjetClient client = new Mailjet.Client.MailjetClient(publicKey, privateKey)
            {
                Version = ApiVersion.V3_1,
            };

            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    { "From", new JObject {
                          { "Email", "*****@*****.**" },
                          { "Name", "Klearthink Services" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", "*****@*****.**" },
                              { "Name", "yasuoyuhao" }
                          }
                      } },
                    { "Subject", "測試中英文 hi, test" },
                    { "TextPart", "測試中英文 hi, test" },
                    { "HTMLPart", "<h3>測試中英文 hi, test</h3><br />May the delivery force be with you!" }
                }
            });

            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()));
            }
        }
Ejemplo n.º 13
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()));
            }
        }
Ejemplo n.º 14
0
        public Task SendEmail(string email, string subject, string message)
        {
            MailjetClient client = new MailjetClient("4b32ae6c7e59763818734d8ef7485137", "dd64861be62fc383493727aa857cc322")
            {
                Version = ApiVersion.V3_1,
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    { "From", new JObject {
                          { "Email", "*****@*****.**" },
                          { "Name", "Mailjet Pilot" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", "*****@*****.**" },
                              { "Name", "passenger 1" }
                          }
                      } },
                    { "Subject", "Your email flight plan!" },
                    { "TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!" },
                    { "HTMLPart", "<h3>Dear passenger 1, welcome to Mailjet!</h3><br />May the delivery force be with you!" }
                }
            });
            MailjetResponse response = client.PostAsync(request).Result;

            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()));
            }

            return(Task.FromResult(0));
        }
        public async Task SendEmailAsync(string email, string subject, string htmlMessage)
        {
            MailjetClient client = new MailjetClient(
                Environment.GetEnvironmentVariable("d76196320fd6439e21c12b3140a89013"),
                Environment.GetEnvironmentVariable("03c778fa8b30e06d24bfe3727509960c")
                )
            {
                Version = ApiVersion.V3_1,
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    { "From", new JObject {
                          { "Email", subject },
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", email },
                          }
                      } },
                    { "HTMLPart", htmlMessage }
                }
            });
            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()));
            }
        }
Ejemplo n.º 16
0
        public async void SendEmail(string destinationEmail, string subject, string body)
        {
            try
            {
                MailjetClient  client  = new MailjetClient(USERNAME, SECRET);
                MailjetRequest request = new MailjetRequest
                {
                    Resource = Send.Resource,
                }
                .Property(Send.FromEmail, EMAIL)
                .Property(Send.FromName, NAME)
                .Property(Send.Subject, subject)
                .Property(Send.TextPart, "")
                .Property(Send.HtmlPart, body)
                .Property(Send.Recipients, new JArray
                {
                    new JObject
                    {
                        { "Email", destinationEmail }
                    }
                });

                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()));
                }
            }
            catch (Exception) { }
        }
Ejemplo n.º 17
0
    public static string FormatForLogs(this MailjetResponse mailjetResponse)
    {
        var sb = new StringBuilder();

        if (!mailjetResponse.IsSuccessStatusCode)
        {
            sb.AppendLine($"StatusCode: {mailjetResponse.StatusCode}");
            sb.AppendLine(($"ErrorInfo: {mailjetResponse.GetErrorInfo()}"));
            sb.AppendLine((mailjetResponse.GetData().ToString()));
            sb.AppendLine(($"ErrorMessage: {mailjetResponse.GetErrorMessage()}"));
        }
        return(sb.ToString());
    }
Ejemplo n.º 18
0
        private void HandleResponse(EmailSettings settings, bool throwIfError, MailjetResponse response)
        {
            if (response.IsSuccessStatusCode)
            {
                return;
            }

            var errorText            = this.localizer.GetAndApplyValues("MailjetError", settings.Subject, settings.ToEmail);
            var emailSenderException = new MailjetException(errorText);

            this.logger.LogError(emailSenderException, response.GetData().ToString());

            if (throwIfError)
            {
                throw emailSenderException;
            }
        }
Ejemplo n.º 19
0
        public async Task SendEmailAsync(string email, string subject, string htmlMessage)
        {
            MailjetClient  client  = new MailjetClient(_mailjetSettings.PublicKey, _mailjetSettings.PrivateKey);
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.FromEmail, _mailjetSettings.Email)

            //상대방이 받았을때 보낸사람의 이름
            .Property(Send.FromName, "From Hidden Villa")

            //메일 제목
            .Property(Send.Subject, subject)

            //뭔지 모름. 메일함에 표시도 안됨
            .Property(Send.TextPart, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")

            //본문내용.
            .Property(Send.HtmlPart, htmlMessage)

            //받는 사람들 목록 정해주기
            .Property(Send.Recipients, new JArray {
                new JObject {
                    //받는 사람의 이메일
                    { "Email", email }
                    , { "Name", "dummyRecipiName" } // 받은 사람의 닉네임 정해주기. 없어도 됨
                }
                , new JObject {
                    { "Email", "*****@*****.**" }
                }
            });
            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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }
        }
Ejemplo n.º 20
0
        private async Task SendMailjetTemplate(string email, string userName, int templateId, string subject, JObject templateVariables)
        {
            var client = new MailjetClient(
                Configuration.GetValue <string>("MailJetApiKey"),
                Configuration.GetValue <string>("MailJetApiSecret"))
            {
                Version = ApiVersion.V3_1
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    { "From", new JObject {
                          { "Email", Configuration.GetValue <string>("MailJetSender") }, { "Name", "Toss" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", email }, { "Name", userName }
                          }
                      } },
                    { "TemplateID", templateId },
                    { "TemplateLanguage", true },
                    { "TemplateErrorDeliver", true },
                    //{"TemplateErrorReporting",new JObject  {{"Email", "" }, {"Name", "Rémi Bourgarel" } } },
                    { "Subject", subject },
                    { "Variables", templateVariables }
                }
            }
                      );
            MailjetResponse response = await client.PostAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception(
                          string.Format("StatusCode: {0}    ", response.StatusCode) +
                          string.Format("ErrorInfo: {0}    ", response.GetErrorInfo()) +
                          string.Format("GetData: {0}    ", response.GetData()) +
                          string.Format("ErrorMessage: {0}    ", response.GetErrorMessage()));
            }
        }
Ejemplo n.º 21
0
Archivo: Mail.cs Proyecto: kigh143/bee
        public static async Task SendViaMailJet(String to, String subject, String msg)
        {
            string senderEmail = (String)Bee.Engine.Hive.SelectToken("email.sender");
            string senderName  = (String)Bee.Engine.Hive.SelectToken("email.name");
            string publickey   = (String)Bee.Engine.Hive.SelectToken("email.publickey");
            string apiSecret   = (String)Bee.Engine.Hive.SelectToken("email.privatekey");


            MailjetClient  client  = new MailjetClient(publickey, apiSecret);
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }.Property(Send.FromEmail, senderEmail)
            .Property(Send.FromName, senderName)
            .Property(Send.Subject, subject)
            .Property(Send.HtmlPart, msg)
            .Property(Send.Recipients, new JArray()
            {
                new JObject {
                    { "Email", to }
                }
            });
            //.Property(Send.TextPart, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
            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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }
        }
Ejemplo n.º 22
0
        static async Task RunAsync()
        {
            //MailjetClientHandler clientHandler = new MailjetClientHandler()
            //{
            //    Proxy = new DefaultProxy("http://127.0.0.1:8888"),
            //    UseProxy = true,
            //};

            //MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"), clientHandler)
            //{
            //    BaseAdress = "https://api.mailjet.com",
            //    Version = ApiVersion.V3,
            //};

            IMailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));

            MailjetRequest request = new MailjetRequest
            {
                Resource = Apikey.Resource,
            };

            MailjetResponse response = await client.GetAsync(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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
            }

            Console.ReadLine();
        }
        public void TestGetAsync()
        {
            int expectedTotal = 1;
            int expectedCount = 1;

            var expectedData = new JArray
            {
                new JObject
                {
                    { Apikey.APIKey, "ApiKeyTest" },
                },
            };

            var mockHttp = new MockHttpMessageHandler();

            string jsonResponse = GenerateJsonResponse(expectedTotal, expectedCount, expectedData);

            // Setup a respond for the user api (including a wildcard in the URL)
            mockHttp.When("https://api.mailjet.com/v3/*")
            .Respond(JsonMediaType, jsonResponse);         // Respond with JSON

            // Inject the handler into your application code
            IMailjetClient client = new MailjetClient(ApiKeyTest, ApiSecretTest, mockHttp);

            MailjetRequest request = new MailjetRequest
            {
                Resource = Apikey.Resource,
            };

            MailjetResponse response = client.GetAsync(request).Result;

            Assert.IsTrue(response.IsSuccessStatusCode);
            Assert.AreEqual(expectedTotal, response.GetTotal());
            Assert.AreEqual(expectedCount, response.GetCount());
            Assert.IsTrue(JToken.DeepEquals(expectedData, response.GetData()));
        }
        private async Task AssertGetContact(long contactId)
        {
            // arrange
            MailjetRequest request = new MailjetRequest
            {
                Resource   = Contact.Resource,
                ResourceId = ResourceId.Numeric(contactId)
            };

            // act
            MailjetResponse response = await _client.GetAsync(request);

            // assert
            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual(1, response.GetCount());
            Assert.AreEqual(1, response.GetTotal());

            var firstObject = response.GetData()[0];

            Assert.AreEqual(true, firstObject.Value <bool>("IsExcludedFromCampaigns"));
            Assert.AreEqual(_contactName, firstObject.Value <string>("Name"));
            Assert.AreEqual(_contactEmail, firstObject.Value <string>("Email"));
            Assert.AreEqual(contactId, firstObject.Value <long>("ID"));
        }
Ejemplo n.º 25
0
        static async Task ProcessEmailMailjet()
        {
            Thread.CurrentThread.Name = "EmailSendWorker";
            while (true)
            {
                OrderEmail email = null;

                email = emailsQueue.Take();
                logger.Debug("{0} Отправка письма из очереди", GetThreadInfo());

                Thread.Sleep(1000);

                if (email == null)
                {
                    continue;
                }

                if (email.StoredEmailId == 0)
                {
                    logger.Debug("{0} Письмо не было сохранено перед добавлением в очередь. Добавлено повторно в очередь", GetThreadInfo());
                    AddEmailToSend(email);
                    continue;
                }

                using (var uow = UnitOfWorkFactory.CreateForRoot <StoredEmail>(email.StoredEmailId, $"[ES]Задача отправки через Mailjet")) {
                    MailjetClient client = new MailjetClient(userId, userSecretKey)
                    {
                        Version = ApiVersion.V3_1,
                    };
                    try {
                        //формируем письмо в формате mailjet для отправки
                        var             request  = CreateOrderMailjetRequest(email);
                        MailjetResponse response = null;
                        try {
                            logger.Debug("{0} Отправка запроса на сервер Mailjet", GetThreadInfo());
                            response = await client.PostAsync(request);
                        }
                        catch (Exception ex) {
                            logger.Error("{1} Не удалось отправить письмо: \n{0}", ex, GetThreadInfo());
                            SaveErrorInfo(uow, ex.ToString());
                            continue;
                        }

                        MailjetMessage[] messages = response.GetData().ToObject <MailjetMessage[]>();

                        logger.Debug("{1} Получен ответ: Code {0}", response.StatusCode, GetThreadInfo());

                        if (response.IsSuccessStatusCode)
                        {
                            uow.Root.State = StoredEmailStates.SendingComplete;
                            foreach (var message in messages)
                            {
                                if (message.CustomID == uow.Root.Id.ToString())
                                {
                                    foreach (var messageTo in message.To)
                                    {
                                        if (messageTo.Email == email.Recipient.EmailAddress)
                                        {
                                            uow.Root.ExternalId = messageTo.MessageID.ToString();
                                        }
                                    }
                                }
                            }
                            uow.Save();
                            logger.Debug(response.GetData());
                        }
                        else
                        {
                            switch (response.StatusCode)
                            {
                            //Unauthorized
                            //Incorrect Api Key / API Secret Key or API key may be expired.
                            case 401:
                                Init();
                                if (email.SendAttemptsCount >= MaxSendAttemptsCount)
                                {
                                    SaveErrorInfo(uow, GetErrors(messages));
                                }
                                else
                                {
                                    emailsQueue.Add(email);
                                }
                                break;

                            //Too Many Requests
                            //Reach the maximum number of calls allowed per minute.
                            case 429:
                                if (email.SendAttemptsCount >= MaxSendAttemptsCount)
                                {
                                    SaveErrorInfo(uow, GetErrors(messages));
                                }
                                else
                                {
                                    emailsQueue.Add(email);
                                }
                                break;

                            //Internal Server Error
                            case 500:
                                SaveErrorInfo(uow, string.Format("Внутренняя ошибка сервера Mailjet: {0}", GetErrors(messages)));
                                break;

                            default:
                                SaveErrorInfo(uow, GetErrors(messages));
                                break;
                            }

                            logger.Debug(response.GetData());
                            logger.Debug("{1} ErrorMessage: {0}\n", response.GetErrorMessage(), GetThreadInfo());
                        }
                    }
                    catch (Exception ex) {
                        logger.Error(ex, "При обработке ответа на отправку письма возникла ошибка.\n");
                    }
                }
            }
        }
Ejemplo n.º 26
0
        //private static readonly String apiBaseUrl = "http://*****:*****@trifork.com" },
                          { "Name", "Driving Notifier App" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", petition.ReplierEmail },
                              { "Name", petition.ReplierEmail }
                          }
                      } },
                    { "Subject", "Your email flight plan!" },
                    { "TemplateLanguage", true },
                    { "HTMLPart", @"<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
  <title>Someone wants to add you!</title>
  <!--[if !mso]><!-- -->
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <!--<![endif]-->

<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style type='text/css'>
  #outlook a { padding: 0; }
  .ReadMsgBody { width: 100%; }
  .ExternalClass { width: 100%; }
  .ExternalClass * { line-height:100%; }
  body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
  table, td { border-collapse:collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
  img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }
  p { display: block; margin: 13px 0; }
</style>
<!--[if !mso]><!-->
<style type='text/css'>
  @media only screen and (max-width:480px) {
    @-ms-viewport { width:320px; }
    @viewport { width:320px; }
  }
</style>
<!--<![endif]-->
<!--[if mso]>
<xml>
  <o:OfficeDocumentSettings>
    <o:AllowPNG/>
    <o:PixelsPerInch>96</o:PixelsPerInch>
  </o:OfficeDocumentSettings>
</xml>
<![endif]-->
<!--[if lte mso 11]>
<style type='text/css'>
  .outlook-group-fix {
    width:100% !important;
  }
</style>
<![endif]-->
<style type='text/css'>
  @media only screen and (min-width:480px) {
    .mj-column-per-100 { width:100%!important; }
  }
</style>
</head>
<body style='background: #F4F4F4;'>
  
  <div class='mj-container' style='background-color:#F4F4F4;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;padding-bottom:0px;padding-top:0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;padding-right:0px;padding-left:0px;' align='center'><table role='presentation' cellpadding='0' cellspacing='0' style='border-collapse:collapse;border-spacing:0px;' align='center' border='0'><tbody><tr><td style='width:600px;'><img alt=' title=' height='auto' src='http://90p1.mjt.lu/tplimg/90p1/b/644m/sr8y.jpeg' style='border:none;border-radius:;display:block;font-size:13px;outline:none;text-decoration:none;width:100%;height:auto;' width='600'></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px 20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 25px 0px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><h1 style='font-size: 20px; font-weight: bold;'>CONTACT wants to add you!</h1></div></td></tr><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 25px 0px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><p style='font-size: 13px; margin: 10px 0;'>Hello,</p><p style='font-size: 13px; margin: 10px 0;'>You have received a new request from CONTACT with the following email: EMAIL . If you know this person and want to add it, please click on the Accept button. Otherwise, if&nbsp; you do not know this person, please click on the Decline button.</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;padding-bottom:0px;padding-top:0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;' align='center'><table role='presentation' cellpadding='0' cellspacing='0' style='border-collapse:separate;' align='center' border='0'><tbody><tr><td style='border:none;border-radius:3px;color:#ffffff;cursor:auto;padding:10px 25px;' align='center' valign='middle' bgcolor='#3782d2'><a href='" + urlAcceptance + @"' style='text-decoration:none;background:#3782d2;color:#ffffff;font-family:Arial, sans-serif;font-size:13px;font-weight:normal;line-height:120%;text-transform:none;margin:0px;' target='_blank'><b>Accept</b></a></td></tr></tbody></table></td><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;' align='center'><table role='presentation' cellpadding='0' cellspacing='0' style='border-collapse:separate;' align='center' border='0'><tbody><tr><td style='border:none;border-radius:3px;color:#ffffff;cursor:auto;padding:10px 25px 10px 25px;' align='center' valign='middle' bgcolor='#c83131'><a href='" + urlDeclination + @"' style='text-decoration:none;background:#c83131;color:#ffffff;font-family:Arial, sans-serif;font-size:13px;font-weight:normal;line-height:120%;text-transform:none;margin:0px;' target='_blank'><b>Decline</b></a></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><p style='font-size: 13px; margin: 10px 0;'>Once you have clicked the linked above, CONTACT and you will become contacts.</p><p style='font-size: 13px; margin: 10px 0;'>&nbsp;</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px 20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 20px 0px 20px;padding-top:0px;padding-bottom:0px;' align='center'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:11px;line-height:22px;text-align:center;'><p style='font-size: 13px; margin: 10px 0;'>This e-mail has been sent to [[EMAIL_TO]], <a href='https://www.youtube.com/watch?v=dQw4w9WgXcQ' style='color:inherit;text-decoration:none;' target='_blank'>click here to unsubscribe</a>.</p></div></td></tr><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 20px 0px 20px;padding-top:0px;padding-bottom:0px;' align='center'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:11px;line-height:22px;text-align:center;'><p style='font-size: 13px; margin: 10px 0;'>DK</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></div>

</body></html>" }
                }
            });
            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()));
            }
        }
Ejemplo n.º 27
0
        //private static readonly String apiBaseUrl = "http://*****:*****@trifork.com" },
                          { "Name", "Driving Notifier App" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", user.Email },
                              { "Name", user.Email }
                          }
                      } },
                    { "Subject", "Welcome to Driving Notifier App!" },
                    { "TemplateLanguage", true },
                    { "HTMLPart", @"<!doctype html>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'>
<head>
  <title>Someone wants to add you!</title>
  <!--[if !mso]><!-- -->
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <!--<![endif]-->
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style type='text/css'>
  #outlook a { padding: 0; }
  .ReadMsgBody { width: 100%; }
  .ExternalClass { width: 100%; }
  .ExternalClass * { line-height:100%; }
  body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
  table, td { border-collapse:collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
  img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }
  p { display: block; margin: 13px 0; }
</style>
<!--[if !mso]><!-->
<style type='text/css'>
  @media only screen and (max-width:480px) {
    @-ms-viewport { width:320px; }
    @viewport { width:320px; }
  }
</style>
<!--<![endif]-->
<!--[if mso]>
<xml>
  <o:OfficeDocumentSettings>
    <o:AllowPNG/>
    <o:PixelsPerInch>96</o:PixelsPerInch>
  </o:OfficeDocumentSettings>
</xml>
<![endif]-->
<!--[if lte mso 11]>
<style type='text/css'>
  .outlook-group-fix {
    width:100% !important;
  }
</style>
<![endif]-->
<style type='text/css'>
  @media only screen and (min-width:480px) {
    .mj-column-per-100 { width:100%!important; }
  }
</style>
</head>
<body style='background: #F4F4F4;'>
  
  <div class='mj-container' style='background-color:#F4F4F4;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;padding-bottom:0px;padding-top:0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;padding-right:0px;padding-left:0px;' align='center'><table role='presentation' cellpadding='0' cellspacing='0' style='border-collapse:collapse;border-spacing:0px;' align='center' border='0'><tbody><tr><td style='width:577px;'><img alt=' title=' height='auto' src='http://90p1.mjt.lu/tplimg/90p1/b/6u2s/1pwj.jpeg' style='border:none;border-radius:;display:block;font-size:13px;outline:none;text-decoration:none;width:100%;height:auto;' width='577'></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px 20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 25px 0px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><h1 style='font-size: 20px; font-weight: bold;'>WELCOME to Driving Notifier App!</h1></div></td></tr><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 25px 0px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><p style='font-size: 13px; margin: 10px 0;'>Hello " + user.FullName + @" ,</p><p style='font-size: 13px; margin: 10px 0;'>From the Driving Notifier Team, we would like to give you our warmest welcome to our App. To start using Driving Notifier App you still need to verify your e-mail by clicking the next button:</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;padding-bottom:0px;padding-top:0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;' align='center'><table role='presentation' cellpadding='0' cellspacing='0' style='border-collapse:separate;' align='center' border='0'><tbody><tr><td style='border:none;border-radius:3px;color:#ffffff;cursor:auto;padding:10px 25px;' align='center' valign='middle' bgcolor='#20a79c'><a href='" + urlVerification + @"' style='text-decoration:none;background:#20a79c;color:#ffffff;font-family:Arial, sans-serif;font-size:13px;font-weight:normal;line-height:120%;text-transform:none;margin:0px;' target='_blank'><b>Verify</b></a></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><p style='font-size: 13px; margin: 10px 0;'>If you have not registered and created a new account, please ignore this message and click <a target='_blank' href='" + urlDeclination + @"' style='color: rgb(32, 167, 156);'><span style='color:#20a79c'>here</span></a>.</p><p style='font-size: 13px; margin: 10px 0;'>THANK YOU for using Driving Notifier.</p><p style='font-size: 13px; margin: 10px 0;'> </p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px 20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 20px 0px 20px;padding-top:0px;padding-bottom:0px;' align='center'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:11px;line-height:22px;text-align:center;'><p style='font-size: 13px; margin: 10px 0;'>This e-mail has been sent to [[EMAIL_TO]], <a href='https://www.youtube.com/watch?v=dQw4w9WgXcQ' style='color:inherit;text-decoration:none;' target='_blank'>click here to unsubscribe</a>.</p></div></td></tr><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 20px 0px 20px;padding-top:0px;padding-bottom:0px;' align='center'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:11px;line-height:22px;text-align:center;'><p style='font-size: 13px; margin: 10px 0;'>DK</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></div>
</body>
</html>" }
                }
            });
            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()));
            }
        }
Ejemplo n.º 28
0
        //private static readonly String apiBaseUrl = "http://*****:*****@trifork.com" },
                          { "Name", "Driving Notifier App" }
                      } },
                    { "To", new JArray {
                          new JObject {
                              { "Email", user.Email },
                              { "Name", user.Email }
                          }
                      } },
                    { "Subject", "Reset Password: Driving Notifier App" },
                    { "TemplateLanguage", true },
                    { "HTMLPart", @"<!doctype html>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'>
<head>
  <title>Someone wants to add you!</title>
  <!--[if !mso]><!-- -->
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <!--<![endif]-->
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style type='text/css'>
  #outlook a { padding: 0; }
  .ReadMsgBody { width: 100%; }
  .ExternalClass { width: 100%; }
  .ExternalClass * { line-height:100%; }
  body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
  table, td { border-collapse:collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
  img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }
  p { display: block; margin: 13px 0; }
</style>
<!--[if !mso]><!-->
<style type='text/css'>
  @media only screen and (max-width:480px) {
    @-ms-viewport { width:320px; }
    @viewport { width:320px; }
  }
</style>
<!--<![endif]-->
<!--[if mso]>
<xml>
  <o:OfficeDocumentSettings>
    <o:AllowPNG/>
    <o:PixelsPerInch>96</o:PixelsPerInch>
  </o:OfficeDocumentSettings>
</xml>
<![endif]-->
<!--[if lte mso 11]>
<style type='text/css'>
  .outlook-group-fix {
    width:100% !important;
  }
</style>
<![endif]-->
<style type='text/css'>
  @media only screen and (min-width:480px) {
    .mj-column-per-100 { width:100%!important; }
  }
</style>
</head>
<body style='background: #F4F4F4;'>
  
  <div class='mj-container' style='background-color:#F4F4F4;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;padding-bottom:0px;padding-top:0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;padding-right:0px;padding-left:0px;' align='center'><table role='presentation' cellpadding='0' cellspacing='0' style='border-collapse:collapse;border-spacing:0px;' align='center' border='0'><tbody><tr><td style='width:577px;'><img alt=' title=' height='auto' src='http://90p1.mjt.lu/tplimg/90p1/b/6vm8/1hks.jpeg' style='border:none;border-radius:;display:block;font-size:13px;outline:none;text-decoration:none;width:100%;height:auto;' width='577'></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px 20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 25px 0px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><h1 style='font-size: 20px; font-weight: bold;'> Driving Notifier App: Password Reset</h1></div></td></tr><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 25px 0px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><p style='font-size: 13px; margin: 10px 0;'>Hello,</p><p style='font-size: 13px; margin: 10px 0;'>We have noticed that you want to reset your password for accessing the App. For doing so, you can use the following code and then update your password:</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;padding-bottom:0px;padding-top:0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:24px;text-align:left;'><p style='font-size: 13px; text-align: center; margin: 10px 0;'><span style='font-family:Lucida Console,Helvetica,Arial,sans-serif'>PASSWORD CODE: " + code + @"</span></p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;background:#ffffff;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;background:#ffffff;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:10px 25px;padding-top:0px;padding-bottom:0px;' align='left'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:13px;line-height:22px;text-align:left;'><p style='font-size: 13px; margin: 10px 0;'> </p><p style='font-size: 13px; margin: 10px 0;'>You can generate a new code as many times as you need it, and later you can reset you password again through the Reset Password section in the main view of our App.</p><p style='font-size: 13px; margin: 10px 0;'>Best regards,</p><p style='font-size: 13px; margin: 10px 0;'>Driving Notifier App</p><p style='font-size: 13px; margin: 10px 0;'> </p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]-->
      <!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0' width='600' align='center' style='width:600px;'>
        <tr>
          <td style='line-height:0px;font-size:0px;mso-line-height-rule:exactly;'>
      <![endif]--><div style='margin:0px auto;max-width:600px;'><table role='presentation' cellpadding='0' cellspacing='0' style='font-size:0px;width:100%;' align='center' border='0'><tbody><tr><td style='text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:20px 0px 20px 0px;'><!--[if mso | IE]>
      <table role='presentation' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td style='vertical-align:top;width:600px;'>
      <![endif]--><div class='mj-column-per-100 outlook-group-fix' style='vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%;'><table role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'><tbody><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 20px 0px 20px;padding-top:0px;padding-bottom:0px;' align='center'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:11px;line-height:22px;text-align:center;'><p style='font-size: 13px; margin: 10px 0;'>This e-mail has been sent to [[EMAIL_TO]], <a href='https://www.youtube.com/watch?v=dQw4w9WgXcQ' style='color:inherit;text-decoration:none;' target='_blank'>click here to unsubscribe</a>.</p></div></td></tr><tr><td style='word-wrap:break-word;font-size:0px;padding:0px 20px 0px 20px;padding-top:0px;padding-bottom:0px;' align='center'><div style='cursor:auto;color:#55575d;font-family:Arial, sans-serif;font-size:11px;line-height:22px;text-align:center;'><p style='font-size: 13px; margin: 10px 0;'>DK</p></div></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso | IE]>
      </td></tr></table>
      <![endif]--></div>
</body>
</html>" }
                }
            });
            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()));
            }
        }
Ejemplo n.º 29
0
        public async Task sendMail()
        {
            {
                MailjetClient client = new MailjetClient(
                    Environment.GetEnvironmentVariable("634a08c3c975a7cd3ef966c18060f758"),
                    Environment.GetEnvironmentVariable("d7c006fbae6f1c952ed8b92f48883f13"))
                {
                    Version = ApiVersion.V3_1,
                };
                MailjetRequest request = new MailjetRequest
                {
                    Resource = Send.Resource,
                }
                .Property(Send.Messages, new JArray {
                    new JObject {
                        {
                            "From",
                            new JObject {
                                { "Email", "*****@*****.**" },
                                { "Name", "riki" }
                            }
                        }, {
                            "To",
                            new JArray {
                                new JObject {
                                    {
                                        "Email",
                                        "*****@*****.**"
                                    }, {
                                        "Name",
                                        "riki"
                                    }
                                }
                            }
                        }, {
                            "Subject",
                            "Greetings from Mailjet."
                        }, {
                            "TextPart",
                            "My first Mailjet email"
                        }, {
                            "HTMLPart",
                            "<h3>Dear passenger 1, welcome to <a href='https://www.mailjet.com/'>Mailjet</a>!</h3><br />May the delivery force be with you!"
                        }, {
                            "CustomID",
                            "AppGettingStartedTest"
                        }
                    }
                });
                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()));
                }
            }
        }
        public async Task SendMail()
        {
            MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("9268d4eb3848a3680d116b3e2d2ed017"), Environment.GetEnvironmentVariable("07ef0e06dc59b48e1252a4d66ac22715"))
            {
                Version = ApiVersion.V3_1,
            };
            MailjetRequest request = new MailjetRequest
            {
                Resource = Send.Resource,
            }
            .Property(Send.Messages, new JArray {
                new JObject {
                    {
                        "From",
                        new JObject {
                            { "Email", "*****@*****.**" },
                            { "Name", "Ngo" }
                        }
                    }, {
                        "To",
                        new JArray {
                            new JObject {
                                {
                                    "Email",
                                    "*****@*****.**"
                                }, {
                                    "Name",
                                    "Ngo"
                                }
                            }
                        }
                    }, {
                        "Subject",
                        "Greetings from Mailjet."
                    }, {
                        "TextPart",
                        "My first Mailjet email"
                    }, {
                        "HTMLPart",
                        "<h3>Dear passenger 1, welcome to <a href='https://www.mailjet.com/'>Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }, {
                        "CustomID",
                        "AppGettingStartedTest"
                    }
                }
            });
            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()));
            }
        }