public static async Task RunAsync(IEmailMsgBuilder emailMsgBuilder) { emailMsgBuilder .AddFrom("JD", "*****@*****.**") .AddTo("JD", "*****@*****.**") .AddSubject("Test from builder") .AddTextPart("This is the text part") .AddHtmlPart(@"<h3>Dear passenger 1, welcome to <a href=""https://www.mailjet.com"">Mailjet</a>!</h3><br />May the delivery force be with you!"); Console.WriteLine("----"); Console.WriteLine(emailMsgBuilder.BuildMsgJson()); Console.WriteLine("----"); Console.WriteLine(JObject.Parse(emailMsgBuilder.BuildMsgJson()).ToString()); var response = await emailMsgBuilder.SendMsg(); 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 void SendEmailConfirmationEmail(User user, string baseClientUrl, IUrlHelper url) { var confirmationToken = _userManager.GenerateEmailConfirmationTokenAsync(user).Result; var confirmationLink = url.Action("ConfirmEmail", "Auth", new { userid = user.Id, token = confirmationToken }, protocol: "http"); var html = string.Format(@" Thank you for registering with the site. Your access to the site will be limited until you verify your eamil address by clicking the link below.<br><br> <a href=""{0}/confirmEmail/{1}"">Click Here to Verify Your Email Address</a>", baseClientUrl, WebUtility.UrlEncode(confirmationLink)); var msg = _emailMsgBuilder .AddFrom("JD", "*****@*****.**") .AddTo(user.KnownAs, user.Email) .AddSubject("Confirm your email") .AddTextPart(confirmationLink) .AddHtmlPart(html); var rsp = await msg.SendMsg(); }