Error when sending Html Mail from ASP.net WebApp

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:

  1. Close Visual Studio
  2. Open a Command Window
  3. regsvr32 cdosys.dll /u
  4. iisreset /restart
  5. regsvr32 cdosys.dll
  6. 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?

Tagged , . Bookmark the permalink.

2 Responses to Error when sending Html Mail from ASP.net WebApp

  1. Jim says:

    I tried this fix, and it didn’t work.

  2. Yaakov Ellis says:

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *