Click here to Skip to main content
12,299,086 members (46,321 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET C#4.0
I m not able to send bulk emails together,still i am not using foreach loop or other Loop.
Please suggest me is it possible to send bulk emails alltogether or not ,Need to use foreach loop

i am only able to send LIKE THIS...........
MailMessage mailMessage = new MailMessage();
               SmtpClient smtpClient = new SmtpClient();
               foreach (string EmailID in EmailAddress)
               {
 

                       mailMessage = new MailMessage(FormEmailAddress, EmailID, Subject, MailMessage);
 
                       smtpClient = new SmtpClient();
                       mailMessage.IsBodyHtml = false;
                       smtpClient.UseDefaultCredentials = true;
 
                       smtpClient.Credentials = new System.Net.NetworkCredential(FormEmailAddress, Password);
 
                   try
                   {
                       smtpClient.Send(mailMessage);
 
                   }
                   catch
                   {
 
                   }
                   finally
                   {
                       mailMessage = null;
                       smtpClient = null;
                   }
                   }
Posted 19-Sep-12 19:36pm
_Kapil828
Edited 19-Sep-12 19:38pm
Mehdi Gholam308.2K
v2
Comments
_Kapil 20-Sep-12 1:57am
   
Thanks for this solution,but i am looking for send mails in bulk so that other recipients don't have information to whom i send this emails.

I hope you understand what i am looking for..........
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Try this link if you want to another approach to send bulk emails.

Automated-Email-Notifications-using-SQL-Server-Job-Schedular

manage-bulk-emails-aspnet
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

If the content is same then why are you going for sending it n+1 times ?
You could simply add To address from your for loop.
MailMessage mailMessage = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
foreach (string EmailID in EmailAddress)
{
mailMessage.Bcc.Add(EmailID); /// see Bcc here
}
mailMessage.Subject = Subject;
mailMessage.From = new MailAddress(FormEmailAddress);
mailMessage.Body = mailMessage;
smtpClient = new SmtpClient();
mailMessage.IsBodyHtml = false;//upto you
smtpClient.UseDefaultCredentials = true; // required ?????
 
smtpClient.Credentials = new System.Net.NetworkCredential(FormEmailAddress, Password); 
 
try
{
smtpClient.Send(mailMessage);
 
}
catch
{
 
}
finally
{
mailMessage = null;
smtpClient = null;
}
  Permalink  
v3
Comments
Venkatesh Mookkan 20-Sep-12 1:50am
   
I don't think, this is a right solution.

Adding all the emailed into the MailMessage.From would expose the email ids to the other users too. If this is an application like sending newsletters to people, I would not do that. May be Bcc, would be the right choice.
sushil.mate 20-Sep-12 1:52am
   
if you want to hide the individual's Email address from other, Add the receivers as a Bcc (blind carbon copy/copies circulating) address instead of a To address.
Kuthuparakkal 20-Sep-12 1:58am
   
I am trying to present an idea/logic. And it's commonsense to use BCC or what.
_Kapil 20-Sep-12 2:16am
   
i am agree with you , but i am looking to send bulk eamils in BCC so please suggest me...
Thanks
_Kapil 20-Sep-12 2:05am
   
i want to send Bulk Mails in BCC but not to send it only send mail at first address...
_Kapil 20-Sep-12 2:05am
   
Have an idea how to send bulk mails in BCC..................

Thanks
Kuthuparakkal 20-Sep-12 2:18am
   
updated soln to send as Bcc

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100