472,791 Members | 953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

send e-mail using smtp is too slow

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
4 7596
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Brown | last post by:
Hi, I have what seems to be a simple problem. But I can not for the life of me find a way to send an integer over a socket. The send method will only accept strings. Here is what I am trying to...
0
by: Piotr Bieniek | last post by:
Hello, I have a problem with UDP sockets. It concerns UdpClient class as well. It throws strange exceptions on subsequent Send calls. Exception is SocketException with native error code 10049. I...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
0
by: Markus Poehler | last post by:
Hi there! I have created NT Service that runs on a Server. It should NET SEND to a specifiv Client in a special case of environment. It does NOT net send. The Messenger Service is running....
1
by: charlies224 | last post by:
Hi, I am writting a software that requires me to make sure the Num Lock is always on and Caps Lock is always off. First, I know how to detect if Num Lock or Caps Lock is on or off (if...
2
by: eSolTec, Inc. 501(c)(3) | last post by:
I'm looking for code samples to send a jpg image from a client machine to a host machine. Both have the same image picWindows picture container. I would like to be able to send the image on one...
11
by: Phil Hunt | last post by:
I am porting an VB6 program to .NET C# There is a NET SEND command in the VB6 program. Just wondering if there is any thing similar in the framework. Thanks.
4
by: gvijayaratnam | last post by:
Hi All, I have a fn prototype as follows void print ( char *Buffer, usigned long bufferSize, int chunkSize ); This fn will accept binary file buffer and the buffer size and the chunk size,...
2
by: SvenV | last post by:
I based my program on the asynchronous client/server example on msdn. There weren't too many modifications to the original code. I just created some extra code to response to different messages. F.e....
7
by: Thomas Mlynarczyk | last post by:
Hello, I was playing around a bit with generators using next() and send(). And I was wondering why an extra send() method was introduced instead of simply allowing an argument for next(). ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.