ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,280 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Team
I want to send email to multiple users and need some help with my logic below;
// Sending email notification to a user.
public static class EmailNotificationToUser
{
public static void SendEmail(string htmlString,string emailGrp, string ToEmail)
{
try
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
message.From = new MailAddress("gcobani.mkontwana@s4.co.za");
List<MailAddress> addresses = new List<MailAddress>();
string[] emilGrp = ToEmail.Split(',');
foreach(string Multiemail in emailGrp)
{
message.To.Add(new MailAddress(Multiemail));
}
message.To.Add(emailGrp);
message.Subject = "ShopFloor AMS Incident Report";
message.IsBodyHtml = true;
message.Body = htmlString;
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("entsagcobza2020@gmail.com", "Telkom800@@");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
}catch(Exception ex)
{
}
}
}