473,471 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Create 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 3498
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 executiontimeout 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.Fields.

Like this:
MailMessage mm=new MailMessag()
mm.Fields["http://schemas.microsoft.com/cdo/configuration/cdosendusing"]=1;//"cdoSendUsingPickup"
mm.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"]="c:\\inetpub\\mailroot\\pickup";
SmtpMail.SmtpServer=smtpserver;
SmtpMail.Send(mm);
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 "cdoSendUsingPickup", "smtpserverpickupdirectory" 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 ApplicationState
variables( to pass datas or event control the thread's lifetime. Here is
two demo pages:

==============start send mail page(code behind code
snippet)=================
private void btnSend_Click(object sender, System.EventArgs e)
{
try
{
Application["sendedcount"] = 0;
Application["completed"] = false;
Application["abortsending"] = 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.Redirect( "checkstatus.aspx" );
}
catch(Exception ex)
{
Response.Write("<br>" + ex.ToString());
}
}

public void Send()
{
for(int i=0;i<1000;i++)
{
bool abort = (bool)Application["abortsending"];
if(abort)
{
break;
}

int count = (int)Application["sendedcount"];

//put the sending mail code here

count++;

Application["sendedcount"] = count;

Thread.Sleep(500);

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

===========checkstatus.aspx(we can put it in a iframe)===========
private void Page_Load(object sender, System.EventArgs e)
{
bool finished = (bool)Application["completed"];

if(finished)
{
Response.Write("<br>Finished sending 1000 mails!");
}
else
{
int count = (int)Application["sendedcount"];
Response.Write("<br>Has sended " + count + " mails!");
}
}

private void btnAbort_Click(object sender, System.EventArgs e)
{
Application["abortsending"] = 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
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...
1
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...
8
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...
1
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
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...
2
by: nuwansl | last post by:
I want to get value from multiple check box but not in array.
2
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....
5
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...
5
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...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.