468,290 Members | 1,965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,290 developers. It's quick & easy.

Sending HTML from system.net.mail

I have a little piece of code that will create an e-mail message from a saved
..htm file and send it.
It seems to work well for just about everyone on the receiving end, except
for a few people that are running a SendMail server. They get the html
rendered as plain text in their Outlook 2003 client after POP'ing the message
off their server.

Here is the code I'm using:
Sub SendMail(ByVal sServer As String, ByVal sTo As String, ByVal sFrom
As String, ByVal sSubject As String, ByVal sBody As String)
Try
'setup variables
Dim client As New System.Net.Mail.SmtpClient(sServer)
Dim message As New System.Net.Mail.MailMessage(sFrom, sTo)
'setup message attributes
message.IsBodyHtml = True
message.Subject = sSubject
message.Body = sBody
message.BodyEncoding = System.Text.Encoding.ASCII
message.SubjectEncoding = System.Text.Encoding.ASCII
'send the mail
client.Send(message)
'cleanup variables
client = Nothing
message = Nothing
Catch ex As Exception
MsgBox("Address " & sTo & " is invalid." & vbCrLf & ex.Message)
End Try
End Sub

I've been looking at some of the posts from other users on this HTML render
issue and people are saying maybe go with an AlternateView. Is this really
necessary or is there a different encoding I could do instead?

Funny thing is that when the user sends the same HTML from Outlook to their
server, the client renders it just fine in HTML.
Oct 13 '06 #1
0 2779

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mr. x | last post: by
6 posts views Thread by Eduardo Rosa | last post: by
1 post views Thread by David Dvali | last post: by
6 posts views Thread by Anuradha | last post: by
7 posts views Thread by Ray Booysen | last post: by
jamesd0142
11 posts views Thread by jamesd0142 | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.