First paste this code to web.config file in configuration section:
<system.net>
<mailSettings>
<smtp>
<network host="mail.abc.com" userName="XYZ@abc.com" password="yourPassword"/>
</smtp>
</mailSettings>
</system.net>
Function for sending the mail:
try
{
System.Net.Mail.MailMessage mailMsg =
new System.Net.Mail.MailMessage();
//From Email Id.. custom domain
System.Net.Mail.MailAddress fromAdd =
new System.Net.Mail.MailAddress("xyz@abc.com");
mailMsg.From = fromAdd;
//Add Receiver's Email
mailMsg.To.Add("ToEmail@Xyz.Abc");
mailMsg.IsBodyHtml = true;
mailMsg.Priority = MailPriority.High;
mailMsg.Subject = "Your Subject";//subject of ur mail
mailMsg.Body = @"Your Message as html
or plain text";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mailMsg);
}
catch (Exception
ex)
{
Console.WriteLine("{0}
Exception caught.", ex);
}