public static void SendEmail()
{
try
{
string ToID = "ToMailId@demo.com",
subject = "TestMail",
message = "Test Mail Message.",
FromId = "FromMailId@demo.com",
username = "user",
password = "pwd",
smtp = "demo.mail.com";
int port = 25;
var loginInfo = new NetworkCredential(username, password);
var msg = new MailMessage(FromId,ToID);
var smtpClient = new SmtpClient(smtp, port);
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = loginInfo;
smtpClient.Send(msg);
}
catch (Exception ex)
{
LogInfo.ExceptionLog(ex, "SendEmail", "SendEmail", true);
}
}
{
try
{
string ToID = "ToMailId@demo.com",
subject = "TestMail",
message = "Test Mail Message.",
FromId = "FromMailId@demo.com",
username = "user",
password = "pwd",
smtp = "demo.mail.com";
int port = 25;
var loginInfo = new NetworkCredential(username, password);
var msg = new MailMessage(FromId,ToID);
var smtpClient = new SmtpClient(smtp, port);
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = loginInfo;
smtpClient.Send(msg);
}
catch (Exception ex)
{
LogInfo.ExceptionLog(ex, "SendEmail", "SendEmail", true);
}
}
No comments:
Post a Comment