Could not access 'CDO.Message' object

M

Martin

Hi,

I have standard code that sends mail from an asp.net application.
The application is running on a production web server.
it uses the standard system.web.mail namespace.

most of the time mail is sent fine. however every so often an error is
reported where mail can't be sent.
upon more closer inspection I find that the line that tries to send mail is
throwing an error and the error generated is

Could not access 'CDO.Message' object

usually a restart of the particular web site /virtual dir does the trick
however now the application is flatly refusing to send mail at all.
the server is win2k3 and sending mail works on other web sites on the same
server.

any help would be appreciated


cheers

martin.
 
K

Kevin Spencer

I have standard code that sends mail from an asp.net application.

I had no idea that there WAS such a thing as "standard code that sends email
from an asp.net application."

Chances are, either there is a bug in the code you "have" or your SMTPserver
is not configured properly for the Relay that you may need because you are
attempting to send FROM an email address that is not on the domain or
machine that the SMTP server resides on.

Of course, without seeing the code I can only guess. Where did you find it?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
M

Martin

Hi Kevin,

Just for your information I have posted my "standard" code below. I
called it standard because it is about the least amout of code needed to be
able to send mail.
anyway I found my problem, the code was running on a web server in our DMZ,
the smtp server was set to a mail server inside our corporate lan.
now this method was working to send email, however occaionally it stops
working for a seemingly inexplicable reason.
The error simply says "could not access CDO mail object" and the inner
exception is "could not connect to the transport."

I have now simply reverted to using "localhost" as the mail server as I
never seem to get an error with this.
However I am not sure why I get an intermittent error when trying to connect
to the mail server inside the LAN - maybe network traffic, - I doubt it is
permissions cause sometimes I can connect to it.

anyway, you asked where I got my "standard" code (posted below), well, I
thought of it all by myself :) with a little help from the documentation and
http://www.systemwebmail.com
there's no copywright on it so feel free to re-use it, although of course I
accept absolutly no respoinsibilty for any loss of data...etc..etc...:)

If you're still reading this I wonder if you could express an opinion about
"suggesstion 6" on this page http://www.systemwebmail.com/faq/4.2.3.aspx
I have re-produced the text below.


Suggestion 6
I have no idea why this suggestion works, but I found it on the web. I
figured I would mention it, just in case Suggestion 1 did not work. Instead
of specifying
SmtpMail.SmtpServer = "127.0.0.1"
try
SmtpMail.SmtpServer.Insert( 0, "127.0.0.1 or your mail server name here")

anyway,

cheers for you time kevin, hope you make good use of my "standard" code :)

cheers

martin.

Dim mail As New MailMessage
mail.To = txtEmailAddress.Text.Trim
mail.Subject = txtSubject.Text.Trim
mail.From = txtFrom.Text.Trim
mail.BodyFormat = MailFormat.Html
mail.Body = txtContent.Text.Trim
Try
Trace.Write("To address is [" & mail.To & "]")
Trace.Write("Subject is [" & mail.Subject & "]")
Trace.Write("Subject is [" & mail.From & "]")
SmtpMail.SmtpServer =
ConfigurationSettings.AppSettings.Get("sSmtpServer")
SmtpMail.Send(mail)
Trace.Write("****SUCCESS****Mail sent scuccessfull")
Catch ex As Exception
Trace.Write("***ERROR*****Mail send NOT scuccessfull")
Trace.Write(ex.Message.ToString())
Trace.Write("About to check inner exception")
While Not ex.InnerException Is Nothing
Trace.Write("--------------------------------")
Trace.Write(("The following InnerException reported: " +
ex.InnerException.ToString()))
ex = ex.InnerException
End While
'Throw ex
End Try
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top