Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. private async void SendMail(Customer c, int listaId)
  2.         {
  3.  
  4.             var message = new MailMessage();
  5.             var body = "<p>Este mensage de notificación es para informarte que tu lista de bodas con el código: " + listaId + "ha sido creada exitosamente, </p> ";
  6.  
  7.             message.To.Add(new MailAddress(c.Email));  // replace with valid value
  8.             message.From = new MailAddress("asanchez@workapps.com.co");  // replace with valid value
  9.             message.Subject = "Tu lista en Cachivaches.com ha sido creada exitosamente";
  10.             message.Body = string.Format(body, 2, 2);
  11.             message.IsBodyHtml = true;
  12.  
  13.             using (var smtp = new SmtpClient())
  14.             {
  15.                 var credential = new NetworkCredential
  16.                 {
  17.                     UserName = "asanchez@workapps.com.co",
  18.                     Password = "password"
  19.                 };
  20.                 smtp.Credentials = credential;
  21.                 smtp.Host = "smtp.office365.com";
  22.                 smtp.Port = 587;
  23.                 smtp.EnableSsl = true;
  24.                 try
  25.                 {
  26.                     await smtp.SendMailAsync(message);
  27.                 }
  28.                 catch
  29.                 {
  30.                 }
  31.  
  32.             }
  33.  
  34.  
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement