Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. private void WelcomeMail(string recipient)
  2. {
  3. MailMessage mailMessage = new MailMessage("MyEmail", recipient);
  4. StringBuilder sbEmailBody = new StringBuilder();
  5.  
  6. sbEmailBody.Append("How can I attach .html file here instead of writing the whole code");
  7.  
  8. mailMessage.IsBodyHtml = true;
  9. mailMessage.Body = sbEmailBody.ToString();
  10. mailMessage.Subject = "Welcome to domain.com";
  11. SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
  12. smtpClient.Credentials = new System.Net.NetworkCredential()
  13. {
  14. UserName = "MyEmail",
  15. Password = "MyPassword"
  16. };
  17. smtpClient.EnableSsl = true;
  18. smtpClient.Send(mailMessage);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement