using System.Net;
using System.Net.Mail;
private string MailFrom = "myMail@gmail.com";
private string MailPassword = "myPassword";
public string MailSubject { get; set; }
public string MailTo { get ; set;}
public string MailBody { get; set; }
public string Attachment { get; set; }
public void SendEmail()
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(MailFrom, MailPassword);
MailMessage msg = new MailMessage(MailFrom, MailTo);
Attachment att = new Attachment (Attachment);
msg.Attachments.Add(att);
msg.Subject = MailSubject;
msg.Body = MailBody;
msg.IsBodyHtml = true;
smtp.EnableSsl = true;
smtp.Send(msg);
}
nice article. if you are maintaining any template for email.. this may help you.
ReplyDeletehttp://aspnettutorialonline.blogspot.com/2012/05/email-template-from-flat-file-or.html