Problem with System.Web.Mail.MailMessage and HTML mail

G

Guest

Hi all!

I'm trying to send a HTML mail using the MailMessage class. Sending the
message works fine, but there is something funny with the received message. I
use the code below to generate and send a sample message. When I recieve it
and open it in Outlook 2003 the style for my table cell is not applied. This
is because the dot (.) before the class in the style tag has been removed!!
If I insert another dot before class definition in the style tag, one is
removed and the result is displayed correctly. If I insert a space before the
dot, the space remains and everything is fine. Why is this happening and
where can I learn more about this? Where should I look for errors: sending or
receiving?

Best Regards

Mikael

Dim strHTMLPage As String = ""

'Head of HTML file
strHTMLPage = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf
strHTMLPage += "<HTML>" & vbCrLf
strHTMLPage += "<HEAD>" & vbCrLf

'style start
strHTMLPage += "<style type=""text/css"">" & vbCrLf
strHTMLPage += "<!--" & vbCrLf

'style class
strHTMLPage += ".DemoClass { height: 18px; font-size: 10px;
font-weight: bold; font-family: verdana; background-color: #adbdce; }" &
vbCrLf

'end of style
strHTMLPage += "-->" & vbCrLf
strHTMLPage += "</style>" & vbCrLf

'end of head
strHTMLPage += "</HEAD>" & vbCrLf
strHTMLPage += "<BODY>" & vbCrLf

'body content
strHTMLPage += "<TABLE width=""250"" height=""25"">" & vbCrLf
strHTMLPage += "<TR>" & vbCrLf
strHTMLPage += "<TD class=DemoClass>" & vbCrLf
strHTMLPage += "Just testing" & vbCrLf
strHTMLPage += "</TD>" & vbCrLf
strHTMLPage += "</TR>" & vbCrLf
strHTMLPage += "</TABLE>" & vbCrLf

'end of body
strHTMLPage += "</BODY>" & vbCrLf
strHTMLPage += "</HTML>" & vbCrLf

Dim Msg As New MailMessage
Msg.To = strTo
Msg.From = strFrom
Msg.Subject = "Test Message"
Msg.BodyFormat = MailFormat.Html
Msg.Body = strHTMLPage

SmtpMail.Send(Msg)
 
G

Guest

First I thought that this was an encoding problem and now I have tried every
encoding available with no luck.

Does anyone have a clue?
 

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,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top