By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 MailFormat.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 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>
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I just ran into the same issue (same message...same conditions).
Switching to text format allows mail to be sent. I suspect it is a
permission issue. I think the mailer is trying to build at least one
attachment to handle the HTML. I'm still investigating.

"Michael" <Mi*****@discussions.microsoft.com> wrote in message news:<1B**********************************@microso ft.com>...
By the way, here's the full error:

[COMException (0x80040605): Unknown Error]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object 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, CultureInfo 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(Obje ct obj, String propName, Object propValue)

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.SetProp(Obje ct obj, String propName, Object 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.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection 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 MailFormat.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 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>

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.