Sending email with System.Web.Mail fails with BodyFormat=Html

C

ChrisA

I'm sending email from my ASP.NET 1.1 app, and it works fine providing the
BodyFormat of the System.Web.Mail.MailMessage is set to Text.

If I change to Html format, it breaks. Here's the code:

Me.Msg = New System.Web.Mail.MailMessage

With Me.Msg

.To = "someToAddress"
.From = "someFromAddress"
.Subject = "subject"
.BodyFormat = Mail.MailFormat.Html
.Body = someTextString
.Priority = MailPriority.Normal

End With

SmtpMail.SmtpServer = "mySmtpServer"
SmtpMail.Send(Me.Msg)

This works fine if the format is Mail.MailFormat.Text, but not Html.

Would greatly appreciate any clues as to cause and cure..

The exception (and inner exception) I get is as follows:

Could not access 'CDO.Message' object.

at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)

at System.Web.Mail.CdoSysHelper.Send(MailMessage message)

at System.Web.Mail.SmtpMail.Send(MailMessage message)

at InTouchWeb.EmailSender.SendEmail() in
c:\inetpub\wwwroot\InTouchWeb\EmailSender.vb:line 36

--------------------------------

Exception has been thrown by the target of an invocation.

at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters)

at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)

at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)

at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)

at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
 
H

hazz

Is mySmtpServer really your smtp server, or is it 'local' through IIS or a
'mail.xxxx.com' server available? -greg
 
C

ChrisA

I've tried it using two smtp servers, one by specifying the IP address of
the server that will eventually be hosting the web application. And also
the smtp server I use for normal email, provided by my ISP. In each case,
it works fine with .BodyFormat = Mail.MailFormat.Text, but not Html.

Chris

hazz said:
Is mySmtpServer really your smtp server, or is it 'local' through IIS or a
'mail.xxxx.com' server available? -greg

ChrisA said:
I'm sending email from my ASP.NET 1.1 app, and it works fine providing
the
BodyFormat of the System.Web.Mail.MailMessage is set to Text.

If I change to Html format, it breaks. Here's the code:

Me.Msg = New System.Web.Mail.MailMessage

With Me.Msg

.To = "someToAddress"
.From = "someFromAddress"
.Subject = "subject"
.BodyFormat = Mail.MailFormat.Html
.Body = someTextString
.Priority = MailPriority.Normal

End With

SmtpMail.SmtpServer = "mySmtpServer"
SmtpMail.Send(Me.Msg)

This works fine if the format is Mail.MailFormat.Text, but not Html.

Would greatly appreciate any clues as to cause and cure..

The exception (and inner exception) I get is as follows:

Could not access 'CDO.Message' object.

at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)

at System.Web.Mail.CdoSysHelper.Send(MailMessage message)

at System.Web.Mail.SmtpMail.Send(MailMessage message)

at InTouchWeb.EmailSender.SendEmail() in
c:\inetpub\wwwroot\InTouchWeb\EmailSender.vb:line 36

--------------------------------

Exception has been thrown by the target of an invocation.

at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)

at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[]
modifiers, CultureInfo culture, String[] namedParameters)

at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)

at System.Web.Mail.LateBoundAccessHelper.SetProp(Type type, Object obj,
String propName, Object propValue)

at System.Web.Mail.LateBoundAccessHelper.SetProp(Object obj, String
propName, Object propValue)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top