Could not access 'CDO.Message' object

  • Thread starter Lars-Erik Aabech
  • Start date
L

Lars-Erik Aabech

Have you set the static SmtpServer property of the SmtpMail class?

You probably have a virtual SMTP server on your local machine but not on the
other machines.
The SmtpServer property defaults to local, but you could set it to ie.
"mail.mycompany.com" and off you go :)

"Could not access 'CDO.Message' object" is a general error message from the
SmtpMail.send method - I've got it if an attachment isn't found, if the
SmtpServer isn't found, etc. etc.
This is definately something that should be addressed ;)

HTH,
Lars-Erik
 
S

Sabin

Hi there,

I built a .NET windows service application, which uses
SystemWeb.Mail.SmtpMail class. On my development machine (XP OS) it runs
well.
When I install the application on other machine (Windows 2000 OS + .NET
Framework 1.1), it rises an exception: "Could not access 'CDO.Message'
object"

What is missing ?

TIA,
Sabin
 
C

Chad Z. Hower aka Kudzu

Lars-Erik Aabech said:
Have you set the static SmtpServer property of the SmtpMail class?

Is CDO also installed? Its not on all machines...
"Could not access 'CDO.Message' object" is a general error message from
the SmtpMail.send method - I've got it if an attachment isn't found, if
the SmtpServer isn't found, etc. etc.
This is definately something that should be addressed ;)

Consider Indy. Not only does it implement much more of the protocol than
WebMail, but it gives very specific exceptions when there is a problem and
also does not require CDO. Its also free.

http://www.indyproject.org/

SMTP demo here:
http://www.atozed.com/indy/
 
L

Lars-Erik Aabech

Is CDO also installed? Its not on all machines...

how can you tell, by the way? (except if it works or not)
Or is that the same as having an smtp virtual server on iis? :p

Lars-Erik
 
C

Chad Z. Hower aka Kudzu

Lars-Erik Aabech said:
how can you tell, by the way? (except if it works or not)

Im not sure of any way to determine if its available or not other than try to
use it.
Or is that the same as having an smtp virtual server on iis? :p

No. Thats something totally different.

With Indy you dont need CDO, and if you use the relay option you dont even
need an SMTP server. :)
 
H

Henrik_the_boss

Even more basic, is to check whether or not the SMTP Service is installed or
not under Add Remove Programs :)
Doubt that the .Net Framework Mail functionality works without the service.

// Henrik
 
P

Paul Whitehurst

To get the exact error thrown when sending the email, you should loop
through the caught exception's inner exception. Looking at the inner
exceptions will give you a much better idea where the problem lies, eg
bad email address, could not find server, etc.

Cheers,

Paul
 
S

Sabin

How should I ? I only use a .NET object. See below my code:

MailMessage oMail = new MailMessage();
SmtpMail.SmtpServer = ...
oMail.From = ...
oMail.To = ...
oMail.Subject = ...
oMail.Body = ...
oMail.BodyFormat = MailFormat.Html;
SmtpMail.Send(oMail);

Thanx,
Sabin
 
A

Alvin Bruney [MVP]

You need to register the cdo mail dll on the affected computer. that will
solve the problem
 
P

Paul Whitehurst

Try something like this...

try
{
SmtpMail.Send
}
catch (Exception e)
{
string errorMessage = "";
Exception curException = e;
while (curException != null)
{
//collect all innner exceptions
errorMessage += curException.Message + "\n";
curException = curException.InnerException;
}
//throw a new exception with errorMessage as it's message...
throw new Exception(errorMessage);
//or log it somewhere...
}

Cheers,

Paul
 

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