Send HTML Email from ASP.NET

G

Guest

I can't seem to get messages to be sent in HTML format. All of my test
messages arrive in my inbox in text format. Please see code below. Am I
missing something? I specified HTML as the body format:

<script language="vb" runat="server">

Sub sendmessage_Click(sender as Object, e as EventArgs)


Dim objMail as New MailMessage()

objMail.To = Email.Text
objMail.From = "(e-mail address removed)"
objMail.BodyFormat = System.Web.Mail.MailFormat.Html

objMail.Subject = "Subject.Text"

objMail.Body = body.text
SmtpMail.SmtpServer = "localhost"

SmtpMail.Send(objMail)
message.Text = "Your Email was sent successfully"

End Sub

</script>

Thanks, Rich
 
G

Guest

Nope, no html there, is that the problem? See below:

<font face="MS Reference Sans Serif" size="2">Body of Message:</b></font><br>
<asp:textbox id="body" TextMode="MultiLine"
Columns="40" Rows="10" runat="server" />
 
M

MWells

Remember that HTML is a markup language. If you users enter "this is a
test" into your textbox, that's perfectly valid HTML and will be emailed to
you and rendered as perfectly ordinary looking text.

If your users enter markup, e.g. "this is a <b>test</b>", then when your
mail reader renders it as HTML, you should see the effects of the markup.


Rich Rekos said:
Nope, no html there, is that the problem? See below:

<font face="MS Reference Sans Serif" size="2">Body of
 
G

Guest

Great, thanks, will do. I am new to this and I guess I expected the html to
magically write itself ;) Thanks!
 
M

MWells

That would be a neat trick, but probably not very pretty.

If the app you're developing really needs some decent HTML-input
capabilities, take a look at;

http://www.richercomponents.com/richtextbox/

RichTextBox allows you to enter your content in a wysiwyg mode. Very clean
and feature-rich. You users will burn incense in your honor.

There are almost certainly other similar controls, and some may be free, so
shop around.
 
G

Guest

Fantastic, thanks for the tip.

Rich

MWells said:
That would be a neat trick, but probably not very pretty.

If the app you're developing really needs some decent HTML-input
capabilities, take a look at;

http://www.richercomponents.com/richtextbox/

RichTextBox allows you to enter your content in a wysiwyg mode. Very clean
and feature-rich. You users will burn incense in your honor.

There are almost certainly other similar controls, and some may be free, so
shop around.
 

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