/* Code to Send Mail using Gmail Host Server Settings in asp.net */
var fromAddress = new MailAddress("FromAddress@abc.com", "Display Name");
var fromAddress = new MailAddress("FromAddress@abc.com", "Display Name");
var toAddress = new MailAddress("ToAddress@abc.com", "Display Name");
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, "GmailPassword")
};
var message = new MailMessage(fromAddress, toAddress)
{
Subject = "MailSubject",
Body = "Mail Body",
IsBodyHtml = true
};
smtp.Send(message);
No comments:
Post a Comment