public PartialViewResult Post(FormModel model) { mailGateway.Send( model.Email + ", [email protected]", "Welcome to our newsletter", "Hi, you subscribed with " + model.Email + " via " + model.PageName ); return(PartialView(model.ViewName, model)); }
public void On(Event <LogEventData> evt) { var added = false; var lastSeen = _lastSeen.GetOrAdd(evt.EventType, k => { added = true; return(DateTime.UtcNow); }); if (!added) { if (lastSeen > DateTime.UtcNow.AddMinutes(-SuppressionMinutes)) { return; } _lastSeen[evt.EventType] = DateTime.UtcNow; } var to = FormatTemplate(_toAddressesTemplate.Value, evt, base.Host); var body = FormatTemplate(_bodyTemplate.Value, evt, base.Host); var subject = FormatTemplate(_subjectTemplate.Value, evt, base.Host).Trim().Replace("\r", "").Replace("\n", ""); if (subject.Length > MaxSubjectLength) { subject = subject.Substring(0, MaxSubjectLength); } var client = new SmtpClient(Host, Port ?? 25) { EnableSsl = EnableSsl ?? false }; if (!string.IsNullOrWhiteSpace(Username)) { client.Credentials = new NetworkCredential(Username, Password); } using (var message = new MailMessage(From, to, subject, body) { IsBodyHtml = true }) { _mailGateway.Send(client, message); } }