string RoMaMailID = System.Configuration.ConfigurationManager.AppSettings.Get("FromMailID");
string RoMaMailServer = System.Configuration.ConfigurationManager.AppSettings.Get("MailServerName");
string RoMaUserName = System.Configuration.ConfigurationManager.AppSettings.Get("USername");
string RoMaPassword = System.Configuration.ConfigurationManager.AppSettings.Get("Password");
string Subject = "Test Mail";
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(RoMaMailServer);
if (!RoMaUserName.ToString().Equals("")) {
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(RoMaUserName, RoMaPassword);
}
client.Port = 465;
client.EnableSsl = true;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage Mail = new System.Net.Mail.MailMessage("Roadside Systems<" + FromMailID+ ">",To, Subject, Message);
Mail.IsBodyHtml = true;
try
{
SendEmail(To, Subject, Message);
Response.Write("Mail send Successfully");
}
catch (Exception Ex)
{
Response.Write(Ex.Message);
}