Click here to Skip to main content
15,915,319 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

How to send the same content and attachment to many persons

Help pl

Regards,
Praveen
Posted

There is a generic routine here: Sending an Email in C# with or without attachments: generic routine.[^]

All you have to do is change the "to" parameter to an array of strings, and the line:
C#
mail.To.Add(new MailAddress(to));
to a loop:
foreach (string toAdd in to)
   {
   mail.To.Add(new MailAddress(toAdd));
   }
 
Share this answer
 
Hi,

C#
//Sending Mail with attachement
MailMessage mail = new MailMessage();
mail.To ="me@mycompany.com;him@hiscompany.com;her@hercompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) ); 
mail.Attachments.Add( attachment );	//add the attachment
SmtpMail.SmtpServer = "smtp.gmail.com";  //your real server goes here
SmtpMail.Send( mail );
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900