Email Problem

B

bondo

I have an unusual error occurring when sending email from an ASP.NET
page. Basically, the first attempt at sending an email fails, whilst
subsequent attempts succeed without any issues. The code looks like
this:

MailMessage msg = new MailMessage();
msg.From = "(e-mail address removed)";
msg.To = "(e-mail address removed)";
msg.Body = "Testing Mail";
msg.BodyFormat = MailFormat.Text;
msg.Subject = "Testing Mail";
SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["MailServer"];
SmtpMail.Send(msg);

The error messages i get by iterating through the inner exceptions of
the thrown exception are:

1st ex - Could not access 'CDO.Message' object
2nd ex - Exception has been thrown by the target of an invocation
3rd ex - The transport failed to connect to the server

I also tried using the Indy.Sockets.IndySMTP from
http://www.atozed.com/indy/ to see if this fixed the problem, but
nope, same issues.

The web server is a win2003 server. The SmtpServer variable is stored
in web.config, and is the IP address of our unix SendMail server. Its
kind of weird that the first attempt fails, then subsequent attempts
(spanning multiple sessions) succeed. Has anyone seen this before?
what did you do to fix it?
 
N

Nick Malik

just a hunch...
you could try turning on SMTP services on the Windows 2003 box and
configuring it to forward all messages to the Unix box, then have your app
use the local server. The Windows SMTP server will be a lot more forgiving
if you are having connection issues, and will get the message delivered on a
retry, without affecting your web app.

Something I read somewhere...

Hope it helps,
--- Nick
 
M

Mark Bond

Hi Nick,

I'll try this on Monday and fingers crossed it will sort it out...

Thanks for the reply!

Mark
 
M

Mark Bond

Yep - that worked a treat, I set the SMTP server on the webserver to
relay to the sendmail server and problem has gone - works every time :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top