NameSpaces:
using System.Net.Mail;
public void Send_Mail()
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add("vishal_verma54@yahoo.com");
mail.From = new MailAddress("jeetu.choudhary13@gmail.com");
mail.Subject = "test mail";
mail.Body = "hi i am jeetu";
SmtpClient smtp = new SmtpClient();
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential("jeetu.choudhary13@gmail.com", "*******");
smtp.EnableSsl = true;
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write("this is exception " + ex.Message);
}
}
using System.Net.Mail;
public void Send_Mail()
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add("vishal_verma54@yahoo.com");
mail.From = new MailAddress("jeetu.choudhary13@gmail.com");
mail.Subject = "test mail";
mail.Body = "hi i am jeetu";
SmtpClient smtp = new SmtpClient();
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential("jeetu.choudhary13@gmail.com", "*******");
smtp.EnableSsl = true;
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write("this is exception " + ex.Message);
}
}
No comments:
Post a Comment