private void SendEmail(string FromEmailAddressText, string[] ToEmailAddressesText, string SubjectText, string EmailBodyText, string EmailServerNameText, string[] BccEmailAddressesText = null)
{
Net.Mail.MailMessage EmailMailMessage = new Net.Mail.MailMessage();
EmailMailMessage.From = new Net.Mail.MailAddress(FromEmailAddressText);
foreach (string ToEmailAddressText in ToEmailAddressesText) {
EmailMailMessage.To.Add(ToEmailAddressText);
}
if (BccEmailAddressesText != null) {
foreach (void BccEmailAddressText_loopVariable in BccEmailAddressesText) {
BccEmailAddressText = BccEmailAddressText_loopVariable;
EmailMailMessage.Bcc.Add(BccEmailAddressText);
}
}
EmailMailMessage.Subject = SubjectText;
EmailMailMessage.Body = EmailBodyText;
Net.Mail.SmtpClient EmailSmtpClient = new Net.Mail.SmtpClient(EmailServerNameText);
EmailSmtpClient.UseDefaultCredentials = false;
EmailSmtpClient.Credentials = new System.Net.NetworkCredential(System.Net.WebUtility.HtmlDecode("Username"), System.Net.WebUtility.HtmlDecode("Password"));
EmailSmtpClient.Send(EmailMailMessage);
}
Send an email
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment