public void SendEmail(string email, string body, string subject, string sender)
{
if (email.Trim() != "" && email.Trim() != " ")
{
if (isEmail(email))
{
try
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
if (sender != "")
{
message.From = new MailAddress(sender);
}
else
{
message.From = new MailAddress("serviceteam@julyservices.com");
}
var emails = email.Split(new Char[] { ',', ';' });
foreach (var to in emails)
{
if (!String.IsNullOrEmpty(to))
message.To.Add(new MailAddress(to));
}
message.To.Add(new MailAddress(email));
message.Subject = subject;
message.Body = body;
message.Priority = System.Net.Mail.MailPriority.High;
message.IsBodyHtml = true;
//SmtpClient smtpClient = new SmtpClient("mail.texaspension.com");
//smtpClient.UseDefaultCredentials = true;
System.Net.Mail.SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "mail.julyservices.com";
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("dp_smtp", "Dp$123456", "julyservices");
smtpClient.Credentials = SMTPUserInfo;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Send(message);
}
catch (Exception ex)
{
throw ex;
}
}
}
}
{
if (email.Trim() != "" && email.Trim() != " ")
{
if (isEmail(email))
{
try
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
if (sender != "")
{
message.From = new MailAddress(sender);
}
else
{
message.From = new MailAddress("serviceteam@julyservices.com");
}
var emails = email.Split(new Char[] { ',', ';' });
foreach (var to in emails)
{
if (!String.IsNullOrEmpty(to))
message.To.Add(new MailAddress(to));
}
message.To.Add(new MailAddress(email));
message.Subject = subject;
message.Body = body;
message.Priority = System.Net.Mail.MailPriority.High;
message.IsBodyHtml = true;
//SmtpClient smtpClient = new SmtpClient("mail.texaspension.com");
//smtpClient.UseDefaultCredentials = true;
System.Net.Mail.SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "mail.julyservices.com";
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("dp_smtp", "Dp$123456", "julyservices");
smtpClient.Credentials = SMTPUserInfo;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Send(message);
}
catch (Exception ex)
{
throw ex;
}
}
}
}
No comments:
Post a Comment