473,698 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SmtpMail.Send with timeout

I have an ASP.Net application that sends Emails on several pages.
The problem is that when the mail server is down from some reason, the
SmtpMail.Send hangs the application for one minute until I get an exception
that the server is not reponsding.
Is there a way to set a timeout for this operation (for example 5 seconds) ?
Is there another solution for it (sending the mail in new thread ?) ?

Thanks

ra***@hotmail.c om
Nov 17 '05 #1
6 2977
Ily
Theres not a lot you can do with the mail object sin Dotnet

You might be better looking at some third party component

Nov 17 '05 #2
but why ?
if she/he need to just do it asynchronously, why she/he need 3rd party
component?

The thread with event rised when the mail couldn't be send is a quite
good solution. But rather for WinForm. In the web the solution I know
is to put mail's in some queue (for example database or flat files with
mails). And use external service (windows service) to handle mail
sending.
If your web application will grow, then a lot of mails will be
generated, and only dedicated service would be able to handle it.

--
best regards
stic

Nov 17 '05 #3
..Net 2.0 has a SmtpClient.Time out parameter. Can you use that?

--
William Stacey [MVP]

"ra294" <ra***@hotmail. com> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl...
I have an ASP.Net application that sends Emails on several pages.
The problem is that when the mail server is down from some reason, the
SmtpMail.Send hangs the application for one minute until I get an
exception that the server is not reponsding.
Is there a way to set a timeout for this operation (for example 5 seconds)
?
Is there another solution for it (sending the mail in new thread ?) ?

Thanks

ra***@hotmail.c om

Nov 17 '05 #4
It's a production application so I don't want to use beta.
BTW, when does .Net 2.0 final will be shipped ?
"William Stacey [MVP]" <st*****@mvps.o rg> wrote in message
news:Od******** ******@TK2MSFTN GP12.phx.gbl...
.Net 2.0 has a SmtpClient.Time out parameter. Can you use that?

--
William Stacey [MVP]

"ra294" <ra***@hotmail. com> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl...
I have an ASP.Net application that sends Emails on several pages.
The problem is that when the mail server is down from some reason, the
SmtpMail.Send hangs the application for one minute until I get an
exception that the server is not reponsding.
Is there a way to set a timeout for this operation (for example 5
seconds) ?
Is there another solution for it (sending the mail in new thread ?) ?

Thanks

ra***@hotmail.c om


Nov 17 '05 #5
Not sure, but VS2005 (w/ .net 2.0) has a go-live license if that helps. I
~think there may just be a RC and then RTM, so it is pretty close. Others
may have better info. Cheers.

"ra294" <ra***@hotmail. com> wrote in message
news:uq******** ******@TK2MSFTN GP10.phx.gbl...
It's a production application so I don't want to use beta.
BTW, when does .Net 2.0 final will be shipped ?
"William Stacey [MVP]" <st*****@mvps.o rg> wrote in message
news:Od******** ******@TK2MSFTN GP12.phx.gbl...
.Net 2.0 has a SmtpClient.Time out parameter. Can you use that?

--
William Stacey [MVP]

"ra294" <ra***@hotmail. com> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl...
I have an ASP.Net application that sends Emails on several pages.
The problem is that when the mail server is down from some reason, the
SmtpMail.Send hangs the application for one minute until I get an
exception that the server is not reponsding.
Is there a way to set a timeout for this operation (for example 5
seconds) ?
Is there another solution for it (sending the mail in new thread ?) ?

Thanks

ra***@hotmail.c om



Nov 17 '05 #6
nov 7, 2005
-- bruce (sqlwork.com)

"ra294" <ra***@hotmail. com> wrote in message
news:uq******** ******@TK2MSFTN GP10.phx.gbl...
It's a production application so I don't want to use beta.
BTW, when does .Net 2.0 final will be shipped ?
"William Stacey [MVP]" <st*****@mvps.o rg> wrote in message
news:Od******** ******@TK2MSFTN GP12.phx.gbl...
.Net 2.0 has a SmtpClient.Time out parameter. Can you use that?

--
William Stacey [MVP]

"ra294" <ra***@hotmail. com> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl...
I have an ASP.Net application that sends Emails on several pages.
The problem is that when the mail server is down from some reason, the
SmtpMail.Send hangs the application for one minute until I get an
exception that the server is not reponsding.
Is there a way to set a timeout for this operation (for example 5
seconds) ?
Is there another solution for it (sending the mail in new thread ?) ?

Thanks

ra***@hotmail.c om



Nov 17 '05 #7

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

Similar topics

3
1618
by: Jimmy | last post by:
I am trying to send an attachment using SmtpMail. I am able to send an Excel or text file, but when I try to send a pdf file, it throws an exception: could not access CDO.Message object. The file size is about 1.92 MB. I was wondering what could be the factors that result in such an exception. I am using C# .Net and Windows XP Pro. Thanks, Jimmy
2
2546
by: Leszek | last post by:
Hello, I have created a simple code to send emails using the MailMessage class and the SmtpMail.Send() method: MailMessage mail = new MailMessage(); mail.From = echidna@somewhere.com; // hard-coded mail.To = platypus@somewhere.com; mail.Subject = "Test"; mail.Body = strMessage;
3
2015
by: JJBW | last post by:
Hi I am having a bit of a problem with SmtpMail. I have a bit of code that should send an email but when it is executed no email turns up. MailMessage mmNotify = new MailMessage(); mmNotify.From = ; mmNotify.To = ; mmNotify.BodyFormat = MailFormat.Text;
5
2146
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. --------------------------------------------------------------------------------
1
2698
by: Jens Øster | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send e-mail addresses out side my company walls. When the e-mail is send on some one in my company it works perfect. I think it is a relay issue. Our system administrator will not allow relaying. In the ASP.Net web.config file I let the web application...
3
9254
by: Jens | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send e-mail addresses out side my company walls. When the e-mail is send on some one in my company it works perfect. I think it is a relay issue. Our system administrator will not allow relaying. In the ASP.Net web.config file I let the web application...
4
7541
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP SP2, and IIS's SMTP and WWW servers are installed. Here is the error trace: System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an...
2
1835
by: kmbarz | last post by:
I'm trying to expand my horizons here by working through an ASP.Net book. When I do the example that uses: Line 55: Mail.From = "feedback@graymad.com" Line 56: SmtpMail.SmtpServer = "localhost" Line 57: SmtpMail.Send(Mail) I get: myemail@comcast.net
6
3200
by: ra294 | last post by:
I have an ASP.Net application that sends Emails on several pages. The problem is that when the mail server is down from some reason, the SmtpMail.Send hangs the application for one minute until I get an exception that the server is not reponsding. Is there a way to set a timeout for this operation (for example 5 seconds) ? Is there another solution for it (sending the mail in new thread ?) ? Thanks ra294@hotmail.com
0
8676
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 usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8608
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.