public ActionResult Send_Email(string Toemail, FormCollection form) { try { OLX_Context cont = new OLX_Context(); Message m = new Message(); m.MessageBody = form["Message_Body"]; m.From = form["Sender_Email"]; m.To = Toemail; cont.Messages.Add(m); cont.SaveChanges(); var api = new MandrillApi("UfOYDeGFVADrZwuEoVdg3g"); var message = new Mandrill.Messages.Message(); message.Subject = "Dummy OLX Message"; message.Text = form["Message_Body"]; message.Text += "\nFROM: "; message.Text += form["Sender_Email"]; message.FromEmail = "*****@*****.**"; message.FromName = "HaZa_OLX"; message.To = new[] { new Mandrill.Messages.Recipient(Toemail, "test") }; api.Send(message); Response.Write("Email Sent"); } catch (Exception ex) { Response.Write("Could not send the e-mail - error: " + ex.Message); } return(null); }
public ActionResult Send() { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de"); var api = new MandrillApi("VVWfyUXm5J4ZJVZ8ziOVzA"); var recipients = new List <Mandrill.Messages.Recipient>(); recipients.Add(new Mandrill.Messages.Recipient("*****@*****.**", "PAUL Kontakt Formular")); string body = ""; foreach (string key in Request.Form) { var value = Request.Form[key]; body += key + System.Environment.NewLine; body += value + System.Environment.NewLine + System.Environment.NewLine; } var msg = new Mandrill.Messages.Message() { To = recipients.ToArray(), FromEmail = "*****@*****.**", Subject = "PAUL WebFormular", Text = body }; api.Send(msg); return(Json(new { success = true })); }
public bool SendEmail(string name, string to, string data, EmailType emailType) { try { string Subject = ""; string HtmlBody = ""; string TextBody = ""; switch (emailType) { case EmailType.subscription: Subject = "Welcome to IBO Virtual"; HtmlBody = GetSubscriptionHtml(name); TextBody = GetSubscriptionText(name); break; case EmailType.resetEmail: Subject = "IBO Virtual Reset Password"; HtmlBody = GetResetMailHtml(name, data); TextBody = GetResetMailText(name, data); break; default: break; } List<Mandrill.Messages.Recipient> recipients = new List<Mandrill.Messages.Recipient>(); Mandrill.Messages.Recipient recipient = new Mandrill.Messages.Recipient(to, name); recipients.Add(recipient); MandrillApi server = new MandrillApi(serverToken); Mandrill.Messages.Message message = new Mandrill.Messages.Message(); message.FromEmail = fromEmail; message.FromName = fromName; message.Subject = Subject; message.Html = HtmlBody; message.Text = TextBody; message.To = recipients.ToArray(); message.TrackOpens = true; MVList<Mandrill.Messages.SendResult> results = server.Send(message); if (results.Count > 0) { Mandrill.Messages.SendResult result = results[0]; if (result.Status == Mandrill.Messages.Status.Sent) { return true; } else { return false; } } } catch { } return false; }
public static void sendAccountActivationEmail() { MandrillApi api = new MandrillApi("3o-nF0RHNIA7k1poegC-_g"); Mandrill.Messages.Message message = new Mandrill.Messages.Message(); Mandrill.Messages.Recipient[] listAddresses = new Mandrill.Messages.Recipient[1]; listAddresses[0] = new Mandrill.Messages.Recipient("*****@*****.**", "Fulanito"); message.FromEmail = "*****@*****.**"; message.FromName = "Contact Manager"; message.Html = "<h1>Testing</h1><p>Probando</p>"; message.Subject = "Testing"; message.TrackClicks = true; message.Important = true; message.To = listAddresses; MVList <Mandrill.Messages.SendResult> result = api.Send(message); string oeoe = ""; }