Thursday, March 22, 2012

SmtpMail Could not access 'CDO.Message' object ONLY with HTML form

Hello,
I've read a lot of threads on this subject, but they typically go back to a
problem with the smtp server configuration. In my case, everything works gr
eat until I uncomment the one line below. Once I set the BodyFormat to MailF
ormat.Html then I get:
HttpException (0x80004005): Could not access 'CDO.Message' object
Otherwise, everything works fine and I get my html tags in plain text. I've
got it working (in plain text) with my local smtp server (as below) and two
ISP's... all throw the same error as soon as I set the format to HTML. The
email addresses have, of co
urse, been edited for the post.
Any ideas?
Thanks,
Michael
<CODE>
MailMessage m = new MailMessage();
m.To = "me@dotnet.itags.org.mydomain.com";
m.From = “me@dotnet.itags.org.mydomain.com”;
m.Subject = "testing";
//m.BodyFormat = MailFormat.Html;
m.Body = "this is my test email body.<br><b>this part is in bold</b>";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(m);
</CODE>By the way, here's the full error:
[COMException (0x80040605): Unknown Error]
[TargetInvocationException: Exception has been thrown by the target of an in
vocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Ob
ject target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[
] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args, ParameterModifier[] modifiers, Cultur
eInfo culture, String[] namedParameters) +473
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder
, Object target, Object[] args) +29
System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj, String
propName, Object propValue)
System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String propName, O
bject propValue)
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String propName, O
bject propValue)
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
System.Web.Mail.SmtpMail.Send(MailMessage message)
tms1.mailtest.btnGo_Click(Object sender, EventArgs e) in mailtest.aspx.cs:64
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
sourceControl, S
tring eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
________________________________________
_______________________
"Michael" wrote:

> Hello,
> I've read a lot of threads on this subject, but they typically go back to
a problem with the smtp server configuration. In my case, everything works
great until I uncomment the one line below. Once I set the BodyFormat to Mai
lFormat.Html then I get:
> HttpException (0x80004005): Could not access 'CDO.Message' object
> Otherwise, everything works fine and I get my html tags in plain text. I've got it
working (in plain text) with my local smtp server (as below) and two ISP's... all t
hrow the same error as soon as I set the format to HTML. The email addresses have,
of
course, been edited for the post.
> Any ideas?
> Thanks,
> Michael
> <CODE>
> MailMessage m = new MailMessage();
> m.To = "me@.mydomain.com";
> m.From = “me@.mydomain.com”;
> m.Subject = "testing";
> //m.BodyFormat = MailFormat.Html;
> m.Body = "this is my test email body.<br><b>this part is in bold</b>";
> SmtpMail.SmtpServer = "localhost";
> SmtpMail.Send(m);
> </CODE>

0 comments:

Post a Comment