"Could not access 'CDO.Message' object" when sending attachments

L

Liz Patton

Here's the exception:

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


We've tried all the suggestions at http://www.systemwebmail.com/, to
no avail. Nevertheless it still seems to be permissions-related,
because we temporarily resolved it by adding all my users to the local
Administrators group. Any ideas?
 
K

Kevin Spencer

The "Unspecified Error" is a real pain in the neck, and can mean any number
of things. Most commonly, it's a Relaying configuration issue with the SMTP
server.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Paul Glavich [MVP - ASP.NET]

As Kevin mentioned, the SMTP server relay config is usually the case, but
there are a couple more. Have a look at http://www.systemwebmail.com for a
lot of tips and answers.

--
- Paul Glavich
Microsoft MVP - ASP.NET


Kevin Spencer said:
The "Unspecified Error" is a real pain in the neck, and can mean any number
of things. Most commonly, it's a Relaying configuration issue with the SMTP
server.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Liz Patton said:
Here's the exception:

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


We've tried all the suggestions at http://www.systemwebmail.com/, to
no avail. Nevertheless it still seems to be permissions-related,
because we temporarily resolved it by adding all my users to the local
Administrators group. Any ideas?
 
G

Guest

I ran into this issue with a project some time ago and came to the same conclusion, that it was permissions related. The solution to the problem ended up being to use a third party SMTP component. We ended up going with IPWorks for .Net, which has been solid, no problems with it. IPWorks is great if you have the budget for it, otherwise, I know there's at least one free SMTP component out there, OpenSMTP, which can be found on SourceForge. At the time, I tried using OpenSMTP, but had problems with it. If I recall correctly, these problems were related to using framework 1.0. Upgrading to 1.1 at the time wasn't an option so I never bothered to see if that would have solved the errors.

Good luck!

Cletus
 
L

Liz Patton

Figured it out -- it had to do with impersonation. 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\<machinename>\ASPNET\Local Settings.
(When I initially went hunting for temp directories all over the drive
I didn't find it because it wasn't there yet!) Then, when sending out
the email, the authenticated users were getting "access denied" when
their identity tried to look into the ASPNET documents tree for
attachment info. So we granted permissions on that dir to my
MYDOMAIN\myusergroup, and the problem went away.

Useful background found in Microsoft KB # 317012 Process and request
identity in ASP.NET:

http://support.microsoft.com/default.aspx?scid=kb;en-us;317012

P.S. -- A plea to Microsoft: Write better error messages! These
permissions problems wouldn't be so horrendously difficult to figure
out if we had something to go on other than "Unspecified error."
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top