Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 20:36pm
_Kapil623
Edited 19-Sep-12 20:38pm
Mehdi Gholam254.1K
v2
Comments
_Kapil at 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 at 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 at 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 at 20-Sep-12 1:58am
   
I am trying to present an idea/logic. And it's commonsense to use BCC or what.
_Kapil at 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 at 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 at 20-Sep-12 2:05am
   
Have an idea how to send bulk mails in BCC..................
 
Thanks
Kuthuparakkal at 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
0 DamithSL 295
1 OriginalGriff 285
2 Sergey Alexandrovich Kryukov 157
3 Afzaal Ahmad Zeeshan 154
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2014
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