System.Web.Mail FAQ

Complete FAQ Listing


4.2.8 "Could not access 'CDO.Message' Object - Part 6 Printer Friendly   Email This FAQ   Discuss

This is an awesome suggestion provided by Elizabeth Patton.

Thanks Elizabeth!
--------------------------------------------------------------------------------------

Thanks for your very useful web site at http://www.systemwebmail.com. I too have just been struggling with the scary "Could not access 'CDO.Message' object" error. Wanted to share my solution so you can add it to your list of suggestions.

Here's the exception we were getting:

System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80004005): Unspecified error

--- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
--- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at MyApp.MyApp.Util.SendEmail(MailMessage& objMail)
--- End of inner exception stack trace --- at MyApp.MyApp.Util.SendEmail(MailMessage& objMail) at MyApp.MI.btnServerSave_Click(Object sender, EventArgs e) --------

Here's the setup: ASP.Net web application using local SMTP mail service to send emails, some with attachments, some without attachments. Web app set to use Windows integrated security with impersonation, so web.config has these entries:

<authentication mode="Windows" />
<identity impersonate="true" />

All worked fine until we went to the email attachments. Either the "unspecified error" exception was thrown, or on other servers the email was sent but the attachments were corrupted. GIFs, TIFs, PDFs, you name it. Turns out that when handling email attachments, CDO does not entirely assume the impersonation identity. Instead, the aspnet_wp.exe process identity defined in machine.config comes into play, same as it would if you were using anonymous access. This process needs to create its own temp directory, found on my machine under c:\Documents and Settings\\ASPNET\Local Settings. Then the authenticated users need to be able to access this as well. So we granted permissions on that dir to my MYDOMAIN\myusergroup. Problem solved!

Useful background found in Microsoft KB # 317012: http://support.microsoft.com/default.aspx?scid=kb;en-us;317012


 

Discuss This FAQ Item
Got a question? Another Suggestion? Want to post your solution? Discuss it below.
New Post
  • CDO.Message "\n" mishandling    [ Reply ]
    • RE: CDO.Message "\n" mishandling    [ Reply ]
      • RE RE: CDO.Message "\n" mishandling    [ Reply ]
      • RE RE: CDO.Message "\n" mishandling    [ Reply ]
    • RE: CDO.Message "\n" mishandling    [ Reply ]
  • It worked for me    [ Reply ]
  • What about Windows Forms?    [ Reply ]
  • Could not access 'CDO.Message' object asp.net    [ Reply ]
    • RE: Could not access 'CDO.Message' object asp.net    [ Reply ]
  • Yeeeeeeeeeeeeees!!!    [ Reply ]
  • 'CDO.Message' Error Could be caused by...    [ Reply ]
  • Attachment Related error    [ Reply ]
  • Another "yeeeeeessssss"    [ Reply ]
  • "Could not access 'CDO.Message' Object    [ Reply ]
  • Could not access 'CDO.Message' object.    [ Reply ]
  • Could not access 'CDO.Message' object.    [ Reply ]
    • RE: Could not access 'CDO.Message' object.    [ Reply ]
  • Yessssss again    [ Reply ]
  • Error handling attachments greater than 100k    [ Reply ]
  • My solution    [ Reply ]
  • could not access cdo.message error only in debug    [ Reply ]
    • RE: could not access cdo.message error only in debug    [ Reply ]
  • test    [ Reply ]
  • could not access cdo.message object    [ Reply ]