Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Exception got while sending email
  2. mail.To.Add(model.To);
  3.  
  4.         mail.From = new MailAddress("sheikh.abm@gmail.com");
  5.  
  6.  
  7.         mail.Subject = model.Subject ;
  8.  
  9.         mail.Body = model.Message;
  10.  
  11.         mail.IsBodyHtml = true;
  12.  
  13.         SmtpClient client = new SmtpClient("localhost:");
  14.         client.UseDefaultCredentials = false;
  15.         client.EnableSsl = true;
  16.         client.Host = "localhost:";
  17.         client.Port = 25;
  18.  
  19.         NetworkCredential credentials = new NetworkCredential(model.To, "abc");
  20.  
  21.         client.Credentials = credentials;
  22.  
  23.         try
  24.         {
  25.             client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
  26.             client.Send(mail);
  27.         }
  28.         catch
  29.         {
  30.  
  31.  
  32.  
  33.         }
  34.         return View("Index");
  35.     }