Guest User

Untitled

a guest
Aug 17th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. Send email from Gmail account using Goddady
  2. public static bool _SendMail(string tMailTo, string tSubject, string tBody, string tAttach)
  3. {
  4. MailMessage mail = new MailMessage();
  5. mail.From = new MailAddress(tMailFrom);
  6. mail.To.Add(tMailTo);
  7. mail.Subject = tSubject;
  8. if (!tAttach.Equals(""))
  9. {
  10. mail.Attachments.Add(new Attachment(tAttach));
  11. }
  12. mail.Body = tBody;
  13. mail.IsBodyHtml = true;
  14.  
  15. SmtpClient smtp = new SmtpClient();
  16. smtp.Host = "relay-hosting.secureserver.net";
  17. smtp.Send(mail);
  18. return true;
  19. }
  20.  
  21. smtp.Credentials = new NetworkCredential(smtpUser, smtpPass);
  22. smtp.EnableSsl = true;
  23.  
  24. <system.net>
  25. <mailSettings>
  26. <smtp deliveryMethod="Network" from="username@gmail.com">
  27. <network host="smtp.gmail.com" userName="username@gmail.com" password="password" enableSsl="true" port="587" />
  28. </smtp>
  29. </mailSettings>
Add Comment
Please, Sign In to add comment