So I am trying to clean up the back end and pretty up my emails. Is there a way to have a include to a html file instead of putting the html in here directly? or maybe a better way to do it?
public void SendWelcomeEmail(int uid)
{
SqlCommand command = EmailCommandList.GetRegisteredEmail;
BciDatabase db = new BciDatabase("db");
command.Parameters["@User_Id"].Value = uid;
using (SqlDataReader dr = db.ExecuteReader(command))
{
Member member = new Member();
if (dr != null && !dr.IsClosed && dr.Read())
{
while (dr.Read())
{
string emailAddress = (string)dr["Email"];
MailMessage mail = new MailMessage();
mail.Subject = "Welcome to the site";
mail.Body = "<html><head></head><body><p>Hello, welcome to the site!</body></html>";
mail.IsBodyHtml = true;
mail.From = new MailAddress("[email protected]");
mail.To.Add(new MailAddress(emailAddress));
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("myemail", "mypass"),
EnableSsl = true
};
client.Send(mail);
}
}
}
}
mail.Body = fileContents;