By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Send HTML Email from ASP.NET

P: n/a
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 = "ri***********@questionmark.com"
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
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
What is body.text?
Is HTML in there?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
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 = "ri***********@questionmark.com"
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

Nov 19 '05 #2

P: n/a
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" />
"Steve C. Orr [MVP, MCSD]" wrote:
What is body.text?
Is HTML in there?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
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 = "ri***********@questionmark.com"
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


Nov 19 '05 #3

P: n/a
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" <Ri*******@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
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" />
"Steve C. Orr [MVP, MCSD]" wrote:
What is body.text?
Is HTML in there?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
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 = "ri***********@questionmark.com"
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


Nov 19 '05 #4

P: n/a
Yes, that looks like it would be the problem. Try typing a simple HTML string
in like: <B>Hello World</B>, and see what happens.

"Rich Rekos" wrote:
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" />
"Steve C. Orr [MVP, MCSD]" wrote:
What is body.text?
Is HTML in there?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
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 = "ri***********@questionmark.com"
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


Nov 19 '05 #5

P: n/a
Great, thanks, will do. I am new to this and I guess I expected the html to
magically write itself ;) Thanks!

"MWells" wrote:
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" <Ri*******@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
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" />
"Steve C. Orr [MVP, MCSD]" wrote:
What is body.text?
Is HTML in there?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
>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 = "ri***********@questionmark.com"
> 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


Nov 19 '05 #6

P: n/a
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.
"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
Great, thanks, will do. I am new to this and I guess I expected the html to magically write itself ;) Thanks!

"MWells" wrote:
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" <Ri*******@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
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" />
"Steve C. Orr [MVP, MCSD]" wrote:

> What is body.text?
> Is HTML in there?
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
>
> "Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
> news:19**********************************@microsof t.com...
> >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 = "ri***********@questionmark.com"
> > 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
>
>
>


Nov 19 '05 #7

P: n/a
Fantastic, thanks for the tip.

Rich

"MWells" wrote:
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.
"Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
Great, thanks, will do. I am new to this and I guess I expected the html

to
magically write itself ;) Thanks!

"MWells" wrote:
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" <Ri*******@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
> 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" />
>
>
> "Steve C. Orr [MVP, MCSD]" wrote:
>
> > What is body.text?
> > Is HTML in there?
> >
> > --
> > I hope this helps,
> > Steve C. Orr, MCSD, MVP
> > http://SteveOrr.net
> >
> >
> >
> > "Rich Rekos" <Ri*******@discussions.microsoft.com> wrote in message
> > news:19**********************************@microsof t.com...
> > >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 = "ri***********@questionmark.com"
> > > 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
> >
> >
> >


Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.