Click here to Skip to main content
16,003,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to send 10000 mails at a time without using foreach,for,while concept in asp.net.Is there any way to do?Any one can help me?By Using for loop it taking more than 1 hour for 1000 mails.
Posted
Comments
Prasad Avunoori 7-May-14 6:09am    
I shouldn't take that much time. There could be some problem with your smtp server

You can add multiple addresses to a single MailMessage object using the To[^] property, which is a collection of MailAddress objects...However sending that much emails in one bunch can get you on spammer's list very easily...

/DamithSL/
You can use also Bcc[^] property in the very same way, in which case receivers will not see others mail address...
 
Share this answer
 
v2
Comments
DamithSL 7-May-14 6:17am    
how about MailMessage.Bcc property :) then receiver will not see other email addresses
Kornfeld Eliyahu Peter 7-May-14 6:21am    
Absolutely right!
Ramu15 7-May-14 6:29am    
I want to show their email address in "to" individually.
Ramu15 7-May-14 6:21am    
If i send like that everyone should see all emailids(10000) to everyone.I not interested to share all emailids to everyone.
Kornfeld Eliyahu Peter 7-May-14 6:23am    
See update according to DamithSL's comment!
You can use SmtpClient.SendAsync Method (MailMessage, Object)[^].
Quote:
Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 7-May-14 8:00am    
But remember that for that he will have to create 10000 MailMessage object on the run...
Yeah !!! There is no other way out. I guess BCC is a good option, but it does not exactly do the same thing as we send the mail directly to the user.

Moreover, after one cycle, we should always dispose the objects. Thus, at a particular time, the system does not run out of memory as it encounters continuous disposal of previous objects.

However, I believe that using a Window Scheduler is a great idea to handle this kind of situations, because it won't have any impact on the Web App, which would run at the background.

What you think?
Kornfeld Eliyahu Peter 7-May-14 8:15am    
The comment wasn't for you but to OP :-)
I think that his design went wrong somewhere - I can't see how that 10000 mail in one time can be a requirement!
I think that some scheduled job will be the best solution (I would think of SQL)...
Yeah correct... :)

Thanks,
Tadit

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