Well, i am glad to tell you that the problem solved:
The body of my message was set to the value of a textarea control.
The reason why i couldn't see html was the replacement of the
characters "<", ">", " " etc. with the special characters: "<",
">", " " and so on.
It seems that if you write an HTML code in textarea or other control,
then the .NET replaces the characters: "<", "<", etc. with the special
characteres above.
In order to get rid of those special characters you can do:
MM.Body = replace(MM.Body , "<", "<")
MM.Body = replace(MM.Body , ">", ">")
.....
and so on
BUT: if you want to solve the problem with even more simple way you
can do:
MM.Body = Me.Textarea1.Va lue.InnerText
This works just fine.
"William LaMartin" <la******@tampa bay.rr.com> wrote in message news:<eP******* *******@TK2MSFT NGP09.phx.gbl>. ..
Here is what works for me:
Dim MM As New System.Web.Mail .MailMessage
Dim S As String
MM.From = Me.txtFromEmail .Text
MM.To = Me.txtToEmail.T ext
MM.Subject = Me.txtSubject.T ext
MM.BodyFormat = System.Web.Mail .MailFormat.Htm l
S = "<html><hea d></head><body>"
S = S & "<p></p>"
S = S & Whatever HTML code you need to put for your message
S = S & "</body></html>"
MM.Body = S
System.Web.Mail .SmtpMail.SmtpS erver = Your SMPT server name (the
name of your computer if you are testing on localhost)
System.Web.Mail .SmtpMail.Send( MM)
"Yossi Naggar" <na****@netvisi on.net.il> wrote in message
news:d3******** *************** ***@posting.goo gle.com... Hello to everyone,
Does anybody know how to send html formatted messages with asp.net?
I tried to send such messages with the code below but the content type is
wrong. The content type is multi-part and not html/text as expected.
The code i use is:
mailmsg.To = "XX*@XXXX.c om"
mailmsg.Subject = "some subject string"
mailmsg.Body = <-- an html format body -->
mailmsg.From = "XX*@XXXX.c om"
mailmsg.BodyFor mat = MailFormat.Html
Try
SmtpMail.SmtpSe rver = "127.0.0.1"
SmtpMail.Send(m ailmsg)
Catch exc As Exception
Response.Write( exc.Message)
Response.End()
End Try