CDOSYS error using HTMLBody (all right with TextBody) in Classic ASP

5.3k Views Asked by At

I have a problem with CDOSYS with HTMLBody on IIS 7.5
Simply, this doesn't work:

Set Mail = CreateObject("CDO.Message")
With Mail
    .Subject = "My mail test"
    .From = "me@localhost"
    .To = "[email protected]"
    .HTMLBody = "My body message"
    .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    .Configuration.Fields.Update
    .Send
End With
Set Mail = Nothing

And throws a misterious "CDO.Message.1 error '80040605' Unknown Error" at line

.HTMLBody = "My body message"

No problem if I change it with

.TextBody = "My body message"

Please, have you got a solution for this?
Thanks in advance

1

There are 1 best solutions below

0
On

Found some kind of solution, though it's not ideal. CDO is supposed to be able to automatically generate the text-only version of your HTMLBody, but perhaps a recent MS update has broken it.

It seems that, where previously I could omit the TextBody property, and just specify HTMLBody, now I have to do either of these two things:

a) Specify TextBody. TextBody = "" does not work, it has to be > ""

b) Specify AutoGenerateTextBody = False

Doing either of those things gets around the error, but results in either no text-only version, or having to make it oneself, which sucks. No idea when this problem began, but afaik one used to be able to specify HTMLBody alone, without a problem. Dang.