private static void SendSMTPMail(string FromEmail, string maskemail, string ToEmail, string SubjectText, string MessageText)
{
string Domain = System.Configuration.ConfigurationManager.AppSettings["Domain"].ToString();
string DomainUserName = System.Configuration.ConfigurationManager.AppSettings["DomainUserName"].ToString();
string DomainPassword = System.Configuration.ConfigurationManager.AppSettings["DomainPassword"].ToString();
string BCC = System.Configuration.ConfigurationManager.AppSettings["BCC"].ToString();
System.Net.Mail.MailMessage MailObject = new System.Net.Mail.MailMessage();
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(Domain);
MailObject.From = new System.Net.Mail.MailAddress(FromEmail, maskemail);
MailObject.To.Add(ToEmail);
MailObject.Bcc.Add(BCC);
NetworkCredential basicAuthenticationInfo = new NetworkCredential(DomainUserName, DomainPassword);
MailObject.Subject = SubjectText;
MailObject.IsBodyHtml = true;
MailObject.Body = "" + MessageText + "";
MailObject.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnFailure;
//smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = basicAuthenticationInfo;
smtp.Send(MailObject);
}
{
string Domain = System.Configuration.ConfigurationManager.AppSettings["Domain"].ToString();
string DomainUserName = System.Configuration.ConfigurationManager.AppSettings["DomainUserName"].ToString();
string DomainPassword = System.Configuration.ConfigurationManager.AppSettings["DomainPassword"].ToString();
string BCC = System.Configuration.ConfigurationManager.AppSettings["BCC"].ToString();
System.Net.Mail.MailMessage MailObject = new System.Net.Mail.MailMessage();
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(Domain);
MailObject.From = new System.Net.Mail.MailAddress(FromEmail, maskemail);
MailObject.To.Add(ToEmail);
MailObject.Bcc.Add(BCC);
NetworkCredential basicAuthenticationInfo = new NetworkCredential(DomainUserName, DomainPassword);
MailObject.Subject = SubjectText;
MailObject.IsBodyHtml = true;
MailObject.Body = "" + MessageText + "";
MailObject.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnFailure;
//smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = basicAuthenticationInfo;
smtp.Send(MailObject);
}
No comments:
Post a Comment