By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

send e-mail using smtp is too slow

P: n/a
I have a web page that at the click of a button must send a bunch (1000+)
emails. Each email is sent individually. I have the code working fine,
using Mail Message classes and smtp and all that. But sometimes even when
I'm just sending one e-mail the web page takes a minutes or so to post. Can
anyone tell me why it is so slow, or how to fix the problem?

To address this I am thinking of just creating a queue table to write the
emails to, then using a .net console app running via sql agent scheduled job
to periodically send the emails in batch mode. However, I worry that this
may also be slow?

Does anyone have a better architecture for this solution? If so give me
some ideas. Thanks!
Dec 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
This may have more to do with your e-mail server, or the security model used
by your server, than with the .Net framework. The SMTP protocol is fairly
simple and assuming you aren't sending anything that requires translation on
the sending side (from HTML to text, for example), then the sending process
itself is pretty quick.

If it is a security model issue, then you should be paying that price only
once for each attempt to send. For example, if it takes 20 seconds to log
in, and 1 second to send an e-mail, then your code should take 21 seconds to
send one email, and 30 seconds to send 10 emails. Make sure that this is
the case by testing your sending mechanism.

Regardless, you shouldn't be holding up the web page to send 1000 emails.
Note that there is an open source SMTP server on CodeProject (I don't know
much about it, though). I'm sure that it is not the only one. Perhaps that
may be a better option than writing an expensive component.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"tparks69" <tp******@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
>I have a web page that at the click of a button must send a bunch (1000+)
emails. Each email is sent individually. I have the code working fine,
using Mail Message classes and smtp and all that. But sometimes even when
I'm just sending one e-mail the web page takes a minutes or so to post.
Can
anyone tell me why it is so slow, or how to fix the problem?

To address this I am thinking of just creating a queue table to write the
emails to, then using a .net console app running via sql agent scheduled
job
to periodically send the emails in batch mode. However, I worry that this
may also be slow?

Does anyone have a better architecture for this solution? If so give me
some ideas. Thanks!

Dec 28 '06 #2

P: n/a
"tparks69" <tp******@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
Can anyone tell me why it is so slow, or how to fix the problem?
May be irrelevant, but have you seen this:
http://msdn2.microsoft.com/en-us/library/x5x13z6h.aspx
?

It's new in v2.
Dec 28 '06 #3

P: n/a
one further note: if you are sending a large amount of e-mails, you may want
to consider using the pickup directory. The SMTP service is already running
async. This allows the system to write your outbound mail as a file to a
directory where the service will pick it up. It's a lot more scalable for
web apps. See:
http://msdn2.microsoft.com/en-us/lib...erymethod.aspx
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.comwrote in message
news:5P******************************@comcast.com. ..
This may have more to do with your e-mail server, or the security model
used by your server, than with the .Net framework. The SMTP protocol is
fairly simple and assuming you aren't sending anything that requires
translation on the sending side (from HTML to text, for example), then the
sending process itself is pretty quick.

If it is a security model issue, then you should be paying that price only
once for each attempt to send. For example, if it takes 20 seconds to log
in, and 1 second to send an e-mail, then your code should take 21 seconds
to send one email, and 30 seconds to send 10 emails. Make sure that this
is the case by testing your sending mechanism.

Regardless, you shouldn't be holding up the web page to send 1000 emails.
Note that there is an open source SMTP server on CodeProject (I don't know
much about it, though). I'm sure that it is not the only one. Perhaps
that may be a better option than writing an expensive component.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"tparks69" <tp******@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
>>I have a web page that at the click of a button must send a bunch (1000+)
emails. Each email is sent individually. I have the code working fine,
using Mail Message classes and smtp and all that. But sometimes even
when
I'm just sending one e-mail the web page takes a minutes or so to post.
Can
anyone tell me why it is so slow, or how to fix the problem?

To address this I am thinking of just creating a queue table to write the
emails to, then using a .net console app running via sql agent scheduled
job
to periodically send the emails in batch mode. However, I worry that
this
may also be slow?

Does anyone have a better architecture for this solution? If so give me
some ideas. Thanks!


Dec 28 '06 #4

P: n/a
nil

Nick Malik [Microsoft] wrote:
one further note: if you are sending a large amount of e-mails, you may want
to consider using the pickup directory. The SMTP service is already running
async. This allows the system to write your outbound mail as a file to a
directory where the service will pick it up. It's a lot more scalable for
web apps. See:
http://msdn2.microsoft.com/en-us/lib...erymethod.aspx
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.comwrote in message
news:5P******************************@comcast.com. ..
This may have more to do with your e-mail server, or the security model
used by your server, than with the .Net framework. The SMTP protocol is
fairly simple and assuming you aren't sending anything that requires
translation on the sending side (from HTML to text, for example), then the
sending process itself is pretty quick.

If it is a security model issue, then you should be paying that price only
once for each attempt to send. For example, if it takes 20 seconds to log
in, and 1 second to send an e-mail, then your code should take 21 seconds
to send one email, and 30 seconds to send 10 emails. Make sure that this
is the case by testing your sending mechanism.

Regardless, you shouldn't be holding up the web page to send 1000 emails.
Note that there is an open source SMTP server on CodeProject (I don't know
much about it, though). I'm sure that it is not the only one. Perhaps
that may be a better option than writing an expensive component.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"tparks69" <tp******@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
>I have a web page that at the click of a button must send a bunch (1000+)
emails. Each email is sent individually. I have the code working fine,
using Mail Message classes and smtp and all that. But sometimes even
when
I'm just sending one e-mail the web page takes a minutes or so to post.
Can
anyone tell me why it is so slow, or how to fix the problem?

To address this I am thinking of just creating a queue table to write the
emails to, then using a .net console app running via sql agent scheduled
job
to periodically send the emails in batch mode. However, I worry that
this
may also be slow?

Does anyone have a better architecture for this solution? If so give me
some ideas. Thanks!
Hi
my self nilesh...and i did coding for sending one mail...but i don't
know how to send single mail to more than one mail id...and this is
required in my application..actually i am developing web application
for one designing institute and there should be facility of sending
mail to vendor from whom institute will purchase books and if any new
book comes in the library then every member of the library will be send
one mail...so for that i neee some help...as members of the institute
are not fix so at run time when i send mail then it should be reach to
everyone...
and as i thought for that i should take the mail id from the member
table and then fetch it in to array and then use that array to send
mail id in the for loop....

plz let me know whatever the case and it's better and i'll be thankful
to you if you can provide me code snippet of how to send one mail to
more than one id at a time or provide me any link that contains
articles on this.....

Thanks & Regards,
nil

Jan 2 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.