I have the following method for sending a simple email:
private void WelcomeMail(string recipient)
{
MailMessage mailMessage = new MailMessage("MyEmail", recipient);
StringBuilder sbEmailBody = new StringBuilder();
sbEmailBody.Append("How can I attach .html file here instead of writing the whole code");
mailMessage.IsBodyHtml = true;
mailMessage.Body = sbEmailBody.ToString();
mailMessage.Subject = "Welcome to domain.com";
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.Credentials = new System.Net.NetworkCredential()
{
UserName = "MyEmail",
Password = "MyPassword"
};
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
}
What should I remove/change/add to send an HTML formatted email?
The HTML file is called responsivemail.html and contains more than 100+ lines of html code (that's the problem).