Code to send Email from C# Code


Code to send Email from C# Code
MailMessage msg = new MailMessage();
msg.From = new MailAddress(mailFrom);
msg.To.Add(mailto);
msg.Subject = mailSubject;
msg.Body = mailBody;
msg.IsBodyHtml = true;
//msg.Attachments.Add(new Attachment(mailAttachment));
SmtpClient smtpclient = new SmtpClient();
NetworkCredential nc = new NetworkCredential("GMail Email ID", "GMail Password");
smtpclient.Credentials = nc;
smtpclient.EnableSsl = true;
smtpclient.Host = "smtp.gmail.com";
smtpclient.Port = 587;
smtpclient.Send(msg);

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...