473,549 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending multiple e-mails. Pickup Directory?

Lau
I need to send 1000 emails from an asp.net website.
Normally I would use System.Web.Mail .MailMessage() to send thru an SMTP
server.
But the large amount of emails results in a timeout. My server administrator
told me to write the emails to the “pickup directory” instead. I know that
JMail can do this in ASP, but how do you do this in asp.net?
--
--------------------

Nov 18 '05 #1
7 3504
Hi Lau,

Thanks for your posting. Regarding on the problem you mentioned, are you
sending 1000 email once in a certain asp.net page's serverside executing
code and cause the page reuqest's executiontime timeout?
If so, as my own opinion, I think there're two means:
1. Since in asp.net we can specify a certain long period of timeout for a
particular page in web.config (such as for a upload page), you can consider
increase the httpRuntime's executiontimeou t for that send mail page.

#<location> Element
http://msdn.microsoft.com/library/en...ationElement.a
sp?frame=true

2. Also, it is not recommeded that we directly write mail files into the
pickup folder. I still suggest you use the sytem.web.mail component, and if
there're large number of mails, you may consider slow down the speed we
sending the mails. For example, build an aspx page which contains an iframe
page ,when the user submit the page to send mail, the main page still
interact with the end user , but we constantly post back the iframe page to
send emails( send a certain number of mails in each post back processing).

In addition, we can also create a background thread in asp.net to do the
sending mail task so as not to block the current executing request thread.

Above are some of my suggestions. If you have any other ideas or questions,
please feel free to post here. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
Lau
Hi Steven,

Thank you for your quick response!

I’ve been studying the subject and found that System.web.mail is based on
CDOSYS and that it is possible to access the underlying schema thru
MailMessage.Fie lds.

Like this:
MailMessage mm=new MailMessag()
mm.Fields["http://schemas.microso ft.com/cdo/configuration/cdosendusing"]=1;//"cdoSendUsingPi ckup"
mm.Fields["http://schemas.microso ft.com/cdo/configuration/smtpserverpicku pdirectory"]="c:\\inetpub\\ mailroot\\picku p";
SmtpMail.SmtpSe rver=smtpserver ;
SmtpMail.Send(m m);
The page is sending emails, but I don’t know if it is thru the pickup
directory?
Is my approach off track?

- Lau

Nov 18 '05 #3
Hi Lau,

Thanks for your response. Yes, the System.Web.Mail is based on the CDO
component and we can directly call the CDOSYS through COM interop. But I
think by default both the System.Web.Mail and CDOSYS will use the pickup
directory under the local SMTP server. Anyway, it's OK that you directly
set the "cdoSendUsingPi ckup", "smtpserverpick updirectory" schems when using
the CDOSYS.

Here is the kb article mentioned this, not sure whether you got the idea
from that :)
http://support.microsoft.com/default...b;en-us;286430

In addition, if the number of the mails you're sending will keep increasing
later, I still suggest that we consider the other approachs such as :
1. divding the sending mail task into multi -post backs( via a iframe page)

2. start a background thread to do the task.

If you have any other questions or ideas, please also feel free to post
here. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Lau
1) Iframe posting back: Isn’t this vulnerable? If the user navigates away
from the page in the middle of the sending process? It is critical that all
mails are send!

2) How do I start a background thread? If I understand your idée is to led
the main thread perform “page_unload and post the page to the client and
then have the background thread performing the sending task. Is this
possible? I thought no threads were alive after page_unload. Also how do I
interact with this thread after a new postback? I need to inform the user on
the sending status.

Thanks again!

- Lau

Nov 18 '05 #5
Hi Lau,

Thanks for your followup.
As for the two questions you mentioned, here are my suggestions in line
1) Iframe posting back: Isn’t this vulnerable? If the user navigates away
from the page in the middle of the sending process? It is critical that all
mails are send!
=============== =============== ==============
yes, if we're using a iframe to constantly post back and send mail, we
should display the sending status on the waiting page and tell the user not
to navigate away. Also, we have to log the currently sended mails(count) in
some application level variables.

2) How do I start a background thread?
=============== =============== ============
In asp.net we can start a background thread just like in desktop app. And
we can communicate with the background thread via ApplicationStat e
variables( to pass datas or event control the thread's lifetime. Here is
two demo pages:

==============s tart send mail page(code behind code
snippet)======= ==========
private void btnSend_Click(o bject sender, System.EventArg s e)
{
try
{
Application["sendedcoun t"] = 0;
Application["completed"] = false;
Application["abortsendi ng"] = false;

ThreadStart start = new ThreadStart( Send );
Thread t = new Thread( start );
t.Priority = ThreadPriority. Lowest;
t.Start();

//give it a second or two to start
Thread.Sleep( 2000 );
Response.Redire ct( "checkstatus.as px" );
}
catch(Exception ex)
{
Response.Write( "<br>" + ex.ToString());
}
}

public void Send()
{
for(int i=0;i<1000;i++)
{
bool abort = (bool)Applicati on["abortsendi ng"];
if(abort)
{
break;
}

int count = (int)Applicatio n["sendedcoun t"];

//put the sending mail code here

count++;

Application["sendedcoun t"] = count;

Thread.Sleep(50 0);

if(count == 1000)
{
Application["completed"] = true;
}
}
}

===========chec kstatus.aspx(we can put it in a iframe)======== ===
private void Page_Load(objec t sender, System.EventArg s e)
{
bool finished = (bool)Applicati on["completed"];

if(finished)
{
Response.Write( "<br>Finish ed sending 1000 mails!");
}
else
{
int count = (int)Applicatio n["sendedcoun t"];
Response.Write( "<br>Has sended " + count + " mails!");
}
}

private void btnAbort_Click( object sender, System.EventArg s e)
{
Application["abortsendi ng"] = true;
}

#checkstatus page will postback itself once after several seconds

=============== =============== =

Hope helps. If you have anything unclear, please feel free to post here.
Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #6
Hi Lau,

Have you had a chance to check the suggestions in my last reply or have
you got any further ideas on this issue? If there're still anything else we
can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #7
' Also, it is not recommeded that we directly write mail files into the
pickup folder.'

Steven, why is this not recommended? I work at a company with 15,000
employees and we are just now implementing a pickup directory so that we do
not have to worry about available connections to the SMTP Server. Where can
I find more information about this and why it is not adviseable?

Thanks,

Geoff

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6440
by: Ben | last post by:
Hi all, In my .php file, I'm using both session_start() and setcookie() before <html> tag. It gives me following warning message: Warning: Cannot modify header information - headers already sent by (output started at D:\Apache Group\Apache2\htdocs\YC\songs.php:4) in D:\Apache Group\Apache2\htdocs\YC\ycphpfunc.php on line 148 My .php...
1
1589
by: Joey Martin | last post by:
I have about 5000 emails in my database. I wrote a basic script that sends an email to all of those email addresses. Usually I have to break it up and only send 300-400 at a time so my script does not timeout. I know I can up my timeout to 45 minutes if I needed to, so that they could all be sent at once, but I do not believe that is a wise...
8
8543
alpnz
by: alpnz | last post by:
Hi, I have a need to send snap reports to various shipping agents. E.g. A PalletCard, A FreightNote, A Consignment Advice, and an Export declaration of Conformity. It is easy enough to code a sendobject event for a button click, however this results in One email for each object, and it is named as per the report name. What I would like to...
1
2402
by: pankhudi | last post by:
How can i send multiple files of different lenghts over a network and using the same socket without the need of closing it in between. and what if this is to be done in JAVA ?
3
2755
by: bcanter | last post by:
I am setting up a user request form to help our IT staff get all of the information required to setup a user account, I would like to send the form to a static address each time that it is submitted but I would also like to send it to whomever is submitting the form. It currently will submit to the static address with no problems but I can't seem...
2
1850
by: nuwansl | last post by:
I want to get value from multiple check box but not in array.
2
2682
by: sat1983 | last post by:
Hi I am beginner to C Sharp. trying to attach a multiple files to a mail. I can attach a single file or i can create multiple object of an Attachment class and add to a mail attachment object. But when i want to do it dynamically to attach multiple file...say my code might be generating one or more files depending on the result set... ...
5
3577
by: wktarin | last post by:
Hi. I'm a relative newcomer to the world of php, and I keep bumping into a problem with a mail () form. I need to send an automatic email to two addresses, but I can't seem to get it to work. One email address works just fine, but I can't get the email sent to two different addresses no matter what I try. Below is my code. If someone could help me...
5
14790
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I've been using stream_context_create() to send cookies along with a file_get_contents() call when requesting a remote page. This is useful if I need to pass information to the remote page that my server can't pass, like a login form. This works perfectly well when I've got a single cookie, or multiple cookies on the same domain and path, but...
0
7541
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7734
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6065
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5107
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1074
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
781
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.