System.Web.Mail FAQ

Complete FAQ Listing


4.2.3 The scary "Could not access 'CDO.Message' object" Printer Friendly   Email This FAQ   Discuss

This is probably the most common error thrown by System.Web.Mail. If you get this error, the FIRST THING TO DO, is to write out all InnerException messages.
This will tell you the true error and it will be easer to fix. See Checking the Exception (READ THIS FIRST) for more information.

Although this error message implies there is a permission problem, typically there isn't. However, after trying everything else, you may will want to try the suggestions listed at Error loading type library/DLL.

Now, on to some suggestions:

Suggestion 1
Specify a valid mail server for the SmtpMail.SmtpServer property. If that property is not set, at least set it to 127.0.0.1. For example:
SmtpMail.SmtpServer = "127.0.0.1"

Suggestion 2
If you are using "localhost" or "127.0.0.1" as the SmtpMail.SmtpServer, you may not have permissions to relay through the IIS SMTP Service. To allow access, open up the IIS Admin MMC. Locate the SMTP Virtual Server, and right-click, then select Properties. On the Access tab, click the Relay button. In the Relay Restrictions dialog, grant your IP address (127.0.0.1) to the Computers listbox. Close down all dialogs, and restart the SMTP Service.

Suggestion 3
If you are using "localhost" or "127.0.0.1" as the SmtpMail.SmtpServer, make sure Anonymous access is allowd. To allow access, open up the IIS Admin MMC. Locate the SMTP Virtual Server, and right-click, then select Properties. On the Access tab, click the Authentication button. Be sure "Anonymous Access" is the only checkbox checked. Close down all dialogs, and restart the SMTP Service.

Suggestion 4
The email address does not have a valid TO address. After iterating through the InnerExceptions, you may find this error message actually has to do with relaying. Try sending a test email to an email address that exists on the server specified by SmtpMail.SmtpServer. If you can send an email to that server, then it is a relay issue. Talk to your mail server administrator about letting your code relay through the mail server.

Suggestion 5
Use a real FROM address that exists on the SmtpMail.SmtpServer. Do not use something like "asdf@asdf.com", or some other bogus address as your MailMessage.FromProperty. More advanced mail servers will catch this, and will deny relaying.

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")

Like I said, I don't know why this would work, but here is the thread: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF8&newwindow=1&threadm=ePdwqQfZDHA.2136%40TK2MSFTNGP10.phx.gbl&rnum=75&prev=/groups%3Fq%3Dcdo.message%2Bgroup:microsoft.public.dotnet.*%26num%3D50%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF8%26newwindow%3
 

Discuss This FAQ Item
Got a question? Another Suggestion? Want to post your solution? Discuss it below.
New Post
  • Different Exception    [ Reply ]
    • RE: Different Exception    [ Reply ]
    • RE: Different Exception    [ Reply ]
    • RE: Different Exception    [ Reply ]
  • Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
  • Could not access 'CDO.Message' object - Unspecified Error    [ Reply ]
    • RE: Could not access 'CDO.Message' object - Unspecified Error    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object - Unspecified Error    [ Reply ]
        • RE: RE RE: Could not access 'CDO.Message' object - Unspecified Error    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object - Unspecified Error    [ Reply ]
  • 451 failed to open files for write    [ Reply ]
    • RE: 451 failed to open files for write    [ Reply ]
      • RE RE: 451 failed to open files for write    [ Reply ]
  • Believe it or not but suggestion 6 worked for me...    [ Reply ]
  • This solved it for me!    [ Reply ]
  • bare newlines/illegal characters    [ Reply ]
    • RE: bare newlines/illegal characters    [ Reply ]
  • Re: Suggestion 6    [ Reply ]
    • RE Re: Suggestion 6    [ Reply ]
  • Suggestion 6    [ Reply ]
  • Mail sending problem fixed.    [ Reply ]
    • RE: Mail sending problem fixed.    [ Reply ]
  • Could not access 'CDO.Message' object    [ Reply ]
    • RE: Could not access 'CDO.Message' object    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object    [ Reply ]
      • RE RE: Could not access 'CDO.Message' object    [ Reply ]
  • THE SOLUTION..    [ Reply ]
    • RE: THE SOLUTION..    [ Reply ]
    • RE: THE SOLUTION..    [ Reply ]
    • RE: THE SOLUTION..    [ Reply ]
    • RE: THE SOLUTION..    [ Reply ]
  • Could not access 'CDO.Message'    [ Reply ]
  • #5 worked for me. nt    [ Reply ]
  • Could not access 'CDO.Message' object    [ Reply ]
  • Windows Service    [ Reply ]
    • RE: Windows Service    [ Reply ]
  • Library Not Registered    [ Reply ]
    • RE: Library Not Registered    [ Reply ]
      • RE RE: Library Not Registered    [ Reply ]
  • Error    [ Reply ]
    • RE: Error    [ Reply ]
    • RE: Error    [ Reply ]
  • Mail issue ..transport lost its connection    [ Reply ]
  • SMTP Send in For...next    [ Reply ]
    • RE: SMTP Send in For...next    [ Reply ]
  • another could not access cdocdo.message object    [ Reply ]
  • ta!    [ Reply ]
  • Could not access CDO.Message - A New One    [ Reply ]
  • Windows 2000 Server with DNS Server    [ Reply ]
  • The scary "Could not access 'CDO.Message' object"    [ Reply ]
  • Doubt about Sending email using SmtpServer    [ Reply ]
  • cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
    • RE: cdo exception    [ Reply ]
  • Could not access CDO.Message object : html vs text    [ Reply ]
    • RE: Could not access CDO.Message object : html vs text    [ Reply ]
      • RE RE: Could not access CDO.Message object : html vs text    [ Reply ]
  • SmtpMail.SmtpServer.insert solved the problem and an explanation    [ Reply ]
  • Two things made CDO work!    [ Reply ]
  • Sending mail from asp.net    [ Reply ]
  • email sending with attachment pdf file above 100kb size    [ Reply ]
    • RE: email sending with attachment pdf file above 100kb size    [ Reply ]
  • What I learned    [ Reply ]
  • This was the solution!    [ Reply ]
  • VirusScan    [ Reply ]
    • RE: VirusScan    [ Reply ]
  • Running On Desktop    [ Reply ]
  • The scary "Could not access 'CDO.Message' object"    [ Reply ]
  • Simplest Way to send a mail in VB.NET    [ Reply ]
  • Could not access 'CDO.Message' object    [ Reply ]
  • Problem in sending mail"Could not access 'CDO.Message' object"    [ Reply ]
  • Library not registered - CDO ( Urgent Help )    [ Reply ]