Connecting Tech Pros Worldwide Forums | Help | Site Map

HTML mail does not work?

Roel Korsten
Guest
 
Posts: n/a
#1: Nov 19 '05
Hello all,

I've got a strange one: I'm sending HTML mail via the System.Web.Mail
namespace:

Dim ObjEmail As New MailMessage
Dim sb As New StringBuilder

ObjEmail.To = 'someone@thisnewsgroup.com
ObjEmail.From = ConfigurationSettings.AppSettings("MailFrom")
ObjEmail.Subject = OnderwerpTextBox.Text
ObjEmail.BodyFormat = MailFormat.Html

ObjEmail.Body = Funcs.Nieuwsbrief(OnderwerpTextBox.Text,
BerichtTextbox.Text.Replace(vbCrLf, "<br>"))

SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("MailSMTP")

SmtpMail.Send(ObjEmail)

In the "Funcs.Nieuwsbrief" method (which populates the body of the e-mail) I
generate the following HTML:

<html>
<head>
<link href='http://www.kubbus.nl/style/styles.css' type='text/css'
rel='stylesheet'>
</head>
<body class='body'>
<table class='table_main' align='center' cellpadding='5' cellspacing='5'>
<tr>
<td colspan='3' align='center'>
<table border='0' cellspacing='0' cellpadding='0' height='124px'
width='100%'
background='http://www.kubbus.nl/images/top1.gif'><tr><td></td></tr></table>
<table border='0' cellspacing='0' cellpadding='0' height='26px' width='100%'
background='http://www.kubbus.nl/images/top2.gif'><tr><td></td></tr></table>
<table border='0' cellspacing='0' cellpadding='0' height='17px' width='100%'
background='http://www.kubbus.nl/images/top3.gif'><tr><td></td></tr></table>
</td>
</tr>
<tr>
<td colspan='3' valign='top' class='table_middle'>
<table align='center' width='70%'>
<tr>
<td colspan='3'><p align='center' class='table_header'>
Dit is het onderwerp
</p>
</td>
</tr>
<tr>
<td colspan='3'><br>
<table align='center'>
<tr>
<td class='content_black'>
Dit is het bericht
<br><br>
</td>
</tr>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan='3' align='center' class='content_black_small'>
© 2005 Café Partycentrum Kubbus - alle rechten voorbehouden
</td>
</tr>
</table>
</body>
</html>

When I look at this HTML in IE the page gets rendered perfectly. When I open
the e-mail, all the style is gone!

What's going on?

Greetings,
Roel Korsten



Kevin Spencer
Guest
 
Posts: n/a
#2: Nov 19 '05

re: HTML mail does not work?


You're using an external style sheet. Windows XP Service Pack 2 disallows
this by default (apparently a security issue), and the user would have to
turn it on to use the style sheet. See the following article on the subject:

http://www.emaillabs.com/articles/em...2_upgrade.html

The solution would be to write the style sheet into the HTML page that is
the body of the email.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Roel Korsten" <spam_sucks> wrote in message
news:OhrhK5czFHA.3836@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hello all,
>
> I've got a strange one: I'm sending HTML mail via the System.Web.Mail
> namespace:
>
> Dim ObjEmail As New MailMessage
> Dim sb As New StringBuilder
>
> ObjEmail.To = 'someone@thisnewsgroup.com
> ObjEmail.From = ConfigurationSettings.AppSettings("MailFrom")
> ObjEmail.Subject = OnderwerpTextBox.Text
> ObjEmail.BodyFormat = MailFormat.Html
>
> ObjEmail.Body = Funcs.Nieuwsbrief(OnderwerpTextBox.Text,
> BerichtTextbox.Text.Replace(vbCrLf, "<br>"))
>
> SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("MailSMTP")
>
> SmtpMail.Send(ObjEmail)
>
> In the "Funcs.Nieuwsbrief" method (which populates the body of the e-mail)
> I
> generate the following HTML:
>
> <html>
> <head>
> <link href='http://www.kubbus.nl/style/styles.css' type='text/css'
> rel='stylesheet'>
> </head>
> <body class='body'>
> <table class='table_main' align='center' cellpadding='5' cellspacing='5'>
> <tr>
> <td colspan='3' align='center'>
> <table border='0' cellspacing='0' cellpadding='0' height='124px'
> width='100%'
> background='http://www.kubbus.nl/images/top1.gif'><tr><td></td></tr></table>
> <table border='0' cellspacing='0' cellpadding='0' height='26px'
> width='100%'
> background='http://www.kubbus.nl/images/top2.gif'><tr><td></td></tr></table>
> <table border='0' cellspacing='0' cellpadding='0' height='17px'
> width='100%'
> background='http://www.kubbus.nl/images/top3.gif'><tr><td></td></tr></table>
> </td>
> </tr>
> <tr>
> <td colspan='3' valign='top' class='table_middle'>
> <table align='center' width='70%'>
> <tr>
> <td colspan='3'><p align='center' class='table_header'>
> Dit is het onderwerp
> </p>
> </td>
> </tr>
> <tr>
> <td colspan='3'><br>
> <table align='center'>
> <tr>
> <td class='content_black'>
> Dit is het bericht
> <br><br>
> </td>
> </tr>
> </td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td colspan='3' align='center' class='content_black_small'>
> © 2005 Café Partycentrum Kubbus - alle rechten voorbehouden
> </td>
> </tr>
> </table>
> </body>
> </html>
>
> When I look at this HTML in IE the page gets rendered perfectly. When I
> open
> the e-mail, all the style is gone!
>
> What's going on?
>
> Greetings,
> Roel Korsten
>
>[/color]


No_spam
Guest
 
Posts: n/a
#3: Nov 19 '05

re: HTML mail does not work?


Thanx Kevin! Now it works like a charm...


Kevin Spencer schreef:
[color=blue]
> You're using an external style sheet. Windows XP Service Pack 2 disallows
> this by default (apparently a security issue), and the user would have to
> turn it on to use the style sheet. See the following article on the subject:
>
> http://www.emaillabs.com/articles/em...2_upgrade.html
>
> The solution would be to write the style sheet into the HTML page that is
> the body of the email.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Ambiguity has a certain quality to it.
>
> "Roel Korsten" <spam_sucks> wrote in message
> news:OhrhK5czFHA.3836@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hello all,
> >
> > I've got a strange one: I'm sending HTML mail via the System.Web.Mail
> > namespace:
> >
> > Dim ObjEmail As New MailMessage
> > Dim sb As New StringBuilder
> >
> > ObjEmail.To = 'someone@thisnewsgroup.com
> > ObjEmail.From = ConfigurationSettings.AppSettings("MailFrom")
> > ObjEmail.Subject = OnderwerpTextBox.Text
> > ObjEmail.BodyFormat = MailFormat.Html
> >
> > ObjEmail.Body = Funcs.Nieuwsbrief(OnderwerpTextBox.Text,
> > BerichtTextbox.Text.Replace(vbCrLf, "<br>"))
> >
> > SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("MailSMTP")
> >
> > SmtpMail.Send(ObjEmail)
> >
> > In the "Funcs.Nieuwsbrief" method (which populates the body of the e-mail)
> > I
> > generate the following HTML:
> >
> > <html>
> > <head>
> > <link href='http://www.kubbus.nl/style/styles.css' type='text/css'
> > rel='stylesheet'>
> > </head>
> > <body class='body'>
> > <table class='table_main' align='center' cellpadding='5' cellspacing='5'>
> > <tr>
> > <td colspan='3' align='center'>
> > <table border='0' cellspacing='0' cellpadding='0' height='124px'
> > width='100%'
> > background='http://www.kubbus.nl/images/top1.gif'><tr><td></td></tr></table>
> > <table border='0' cellspacing='0' cellpadding='0' height='26px'
> > width='100%'
> > background='http://www.kubbus.nl/images/top2.gif'><tr><td></td></tr></table>
> > <table border='0' cellspacing='0' cellpadding='0' height='17px'
> > width='100%'
> > background='http://www.kubbus.nl/images/top3.gif'><tr><td></td></tr></table>
> > </td>
> > </tr>
> > <tr>
> > <td colspan='3' valign='top' class='table_middle'>
> > <table align='center' width='70%'>
> > <tr>
> > <td colspan='3'><p align='center' class='table_header'>
> > Dit is het onderwerp
> > </p>
> > </td>
> > </tr>
> > <tr>
> > <td colspan='3'><br>
> > <table align='center'>
> > <tr>
> > <td class='content_black'>
> > Dit is het bericht
> > <br><br>
> > </td>
> > </tr>
> > </td>
> > </tr>
> > </table>
> > </td>
> > </tr>
> > <tr>
> > <td colspan='3' align='center' class='content_black_small'>
> > © 2005 Café Partycentrum Kubbus - alle rechten voorbehouden
> > </td>
> > </tr>
> > </table>
> > </body>
> > </html>
> >
> > When I look at this HTML in IE the page gets rendered perfectly. When I
> > open
> > the e-mail, all the style is gone!
> >
> > What's going on?
> >
> > Greetings,
> > Roel Korsten
> >
> >[/color][/color]

Closed Thread