- The following method sends mail to another user in C sharp
- Add Namespace File,
using System.Net;
using System.Net.Mail;
Public void
SendEmail(string Message, string EmailID)
{
try
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("sudamtambe44@gmail.com");
mail.To.Add(EmailID);
mail.Subject = "Application Status";
mail.Body = Message;
SmtpClient smtp = new SmtpClient("smtp.office365.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("sudamtambe44@gmail.com", "abcd*88");
smtp.Send(mail);
}
catch (SmtpException ex)
{
lblerror.Text = cnclss.SendExcepToDB(pageName, MethodBase.GetCurrentMethod().Name.ToString(), HttpContext.Current.Request.Url.ToString(), ex);
}
}
Comments
Post a Comment