BC30456: 'IsBodyHtml' is not a member of 'System.Net.Mail.SmtpClient'

L

les

I'm getting this error "BC30456: 'IsBodyHtml' is not a member of
'System.Net.Mail.SmtpClient'" when trying to submit a form and send
email.

If I remove the line "MailObj.IsBodyHtml = True" the mail sends
without error, but html markup is visible in the body of the email.

Any suggestions?

Code below:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
if ispostback then
Dim MailObj As New System.Net.Mail.SmtpClient
EmFrom.Text="(e-mail address removed)"
EmTo.Text="(e-mail address removed)"
EmSubj.Text="Subject Here"
EmMsg.Text="<b>Some html here....</b>"
MailObj.Host = "localhost"
MailObj.IsBodyHtml = True
MailObj.Send(EmFrom.Text, EmTo.Text, EmSubj.Text, EmMsg.Text)
end if
End Sub

Thanks
Leslie
 
P

Patrice

Just check the documentation : IsBodyHtml doesn't belong to SmtpClient but
to MailMessage.
 
J

Johnny Jörgensen

A small sample that works for me:

Dim oMail As System.Net.Mail.MailMessage
Dim oFrom As System.Net.Mail.MailAddress
Dim oSmtp As System.Net.Mail.SmtpClient

oMail = New System.Net.Mail.MailMessage
oFrom = New System.Net.Mail.MailAddress("(e-mail address removed)", "Testing")
oSmtp = New System.Net.Mail.SmtpClient("smtpout.test.com")

oMail.From = oFrom
oMail.To.Add("(e-mail address removed)")
oMail.Subject = "My subject"
oMail.Priority = Net.Mail.MailPriority.Normal
oMail.IsBodyHtml = False
oMail.Body = "<b>This is my message</b>"

oSmtp.Send(oMail)


Cheers,
Johnny J.
 
L

les

Thanks Patrice. I've got this now and it works fine:


Dim Frm_Mail As System.Net.Mail.MailMessage = New
System.Net.Mail.MailMessage ()
Frm_Mail.To.Add ( New System.Net.Mail.MailAddress ( "(e-mail address removed)" ) )
'Frm_Mail.Bcc.Add ( New System.Net.Mail.MailAddress ( "(e-mail address removed)" )
)
Frm_Mail.From = new System.Net.Mail.MailAddress ( "(e-mail address removed)" )
Frm_Mail.Subject = "Service Database Feedback"
Frm_Mail.Priority = System.Net.Mail.MailPriority.High
Frm_Mail.IsBodyHtml = True
Frm_Mail.Body = "some html here"
Dim Smtp As New System.Net.Mail.SmtpClient ()
Smtp.Host = "localhost"
Smtp.Send ( Frm_Mail )
 

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

Top