0% found this document useful (0 votes)
36 views

Email To Multiple Users

The document describes sending an email to multiple recipients using C# and .NET. It initializes a MailMessage object and sets the from, to, subject, and HTML body. It connects to an SMTP server using SSL and credentials and sends the email. Any errors are caught and handled. The process demonstrates how to programmatically send an email with attachments to a list of users.

Uploaded by

Raghu Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Email To Multiple Users

The document describes sending an email to multiple recipients using C# and .NET. It initializes a MailMessage object and sets the from, to, subject, and HTML body. It connects to an SMTP server using SSL and credentials and sends the email. Any errors are caught and handled. The process demonstrates how to programmatically send an email with attachments to a list of users.

Uploaded by

Raghu Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

8/27/2017 Email to multiple users

Email to multiple users


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using System.Net.Mail;
using System.Net;

namespace FileAndDocumentUploading.Controllers
{
public class SendMailController : Controller
{
//
// GET: /SendMail/

public ActionResult Index()


{

try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

mail.From = new MailAddress("[email protected]");


mail.To.Add("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Password Recovery ";
mail.Body += " <html>";
mail.Body += "<body>";
mail.Body += "<table>";

mail.Body += "<tr>";
mail.Body += "<td>User Name : </td><td> HAi </td>";
mail.Body += "</tr>";

mail.Body += "<tr>";
mail.Body += "<td>Password : </td><td>aaaaaaaaaa</td>";
mail.Body += "</tr>";

mail.Body += "</table>";
mail.Body += "</body>";
mail.Body += "</html>";

mail.IsBodyHtml = true;

////System.Net.Mail.Attachment attachment;
////attachment = new System.Net.Mail.Attachment(@"D:\bkup\krishna.mdb");
////mail.Attachments.Add(attachment);

SmtpServer.Port = 587;
SmtpServer.Credentials = new
System.Net.NetworkCredential("[email protected]", "password");

http://ganeshmvc4.blogspot.in/p/using-system-using-system.html 1/2
8/27/2017 Email to multiple users

SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);

}
catch (Exception err)
{

}
return View();
}

}
}

http://ganeshmvc4.blogspot.in/p/using-system-using-system.html 2/2

You might also like