public async Task <Response> SendMail(MailSendingModel model) { var msg = MailHelper.CreateSingleEmail(model.From, model.ReplyTo, model.Subject, model.PlainTextContent, model.HtmlContent); var response = await _client.SendEmailAsync(msg); if (response.StatusCode != System.Net.HttpStatusCode.Accepted) { throw new ApplicationException(response.StatusCode.ToString()); } return(response); }
public async Task <MailSendingModel> PrepareEmail(EmailParameters emailParams) { MailSendingModel email = new MailSendingModel(); emailParams.MailTo = _toMail; Dictionary <string, string> parameters = MailerParser.PrepareDictionaryParams(emailParams); var emailtemplate = (await _messagetTemplateRepository.GetAsync(Filtering(emailParams.Cause))) .OrderByDescending(x => x.CreateOn) .FirstOrDefault(); if (emailtemplate != null) { email.Subject = MailerParser.ProcessTemplate(emailtemplate.Subject, parameters); email.From = new EmailAddress(_from); email.To.AddRange(_to?.Select(x => new EmailAddress(x)) ?? new List <EmailAddress>()); //email.To.AddRange(emailParams.EmailsTo?.Select(x => new EmailAddress(x)) ?? new List<EmailAddress>());/ email.HtmlContent = MailerParser.ProcessTemplate(emailtemplate.MessageBody, parameters); return(email); } throw new ArgumentNullException("Message", "Email template not found"); }
public IActionResult Contact(MailSendingModel model) { model.SendingMail(); return(View(model)); }
public IActionResult Contact() { var model = new MailSendingModel(); return(View(model)); }