Error when sending Html Mail from ASP.net WebApp
Posted on September 27, 2006 at 13:10
On an ASP.net site (1.1), I was trying to send an email message using good old SmtpMail.Send(MailMessage message). When I did so, I got the following message “could not access CDO.message object“. After some Googling, I tried out all of the different security/smtp/relary/permissions related suggestions (most can be found on the systemwebmail.com site, a very handy reference if you have some questions regarding use of the System.Web.Mail library in ASP.net 1.1). Still not working. I checked the InnerException. It looked something like this:
InnerException: {”Unknown Error” }
Message: “Exception has been thrown by the target of an invocation.”
Source: “mscorlib”
StackTrace:
” at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)\r\n
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)\r\n
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)\r\n
at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj, String propName, Object propValue)\r\n
at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String propName, Object propValue)”
But nothing apparently wrong there. The one weird thing that I could find is that if I set MailMessage.BodyFormat = MailFormat.Html, it would not work. If I set it to MailFormat.Text, it would work fine. Very suspicious.
In the end, the following solution worked for me. It was posted by Kyle Parker on the DotNetNuke forums:
- Close Visual Studio
- Open a Command Window
- regsvr32 cdosys.dll /u
- iisreset /restart
- regsvr32 cdosys.dll
- resume work in VS
After unregistering and reregistering this DLL, suddenly I was able to send Html mail again from my site. Kyle reported on his post that this only worked as a temporary solution. It is working for me so far.
Anyone know why this happened? Some other program messed up the dll that handles Html mail?
2 Responses to “ Error when sending Html Mail from ASP.net WebApp”
1) Jim on Oct 9, 2006 | Reply
I tried this fix, and it didn’t work.
2) Yaakov Ellis on Oct 9, 2006 | Reply
Jim - Did you take a look at the SystemWebMail site linked to above? They have a dozen other solutions that though they didn’t work for me, might work for you.