3,597 questions
Sending email to multiple uers using asp.net mvc5
gcobani.mkontwana
1
Reputation point
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("******@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("******@gmail.com", "Telkom800@@");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
}catch(Exception ex)
{
}
}
}
Developer technologies ASP.NET Other
Sign in to answer