Send HTML Email from ASP.NET

Discussion in 'ASP .Net' started by =?Utf-8?B?UmljaCBSZWtvcw==?=, Jan 12, 2005.

  1. 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 = ""
    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
    =?Utf-8?B?UmljaCBSZWtvcw==?=, Jan 12, 2005
    #1
    1. Advertising

  2. What is body.text?
    Is HTML in there?

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



    "Rich Rekos" <> wrote in message
    news:...
    >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 = ""
    > 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
    Steve C. Orr [MVP, MCSD], Jan 12, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > >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 = ""
    > > 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

    >
    >
    >
    =?Utf-8?B?UmljaCBSZWtvcw==?=, Jan 12, 2005
    #3
  4. 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" <> wrote in message
    > > news:...
    > > >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 = ""
    > > > 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

    > >
    > >
    > >
    =?Utf-8?B?VGVycnk=?=, Jan 12, 2005
    #4
  5. =?Utf-8?B?UmljaCBSZWtvcw==?=

    MWells Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > > news:...
    > > >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 = ""
    > > > 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

    > >
    > >
    > >
    MWells, Jan 12, 2005
    #5
  6. 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > > news:...
    > > > >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 = ""
    > > > > 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
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?UmljaCBSZWtvcw==?=, Jan 12, 2005
    #6
  7. =?Utf-8?B?UmljaCBSZWtvcw==?=

    MWells Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > > news:...
    > > > 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" <> wrote in message
    > > > > news:...
    > > > > >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 = ""
    > > > > > 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
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
    MWells, Jan 12, 2005
    #7
  8. 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > > news:...
    > > > > 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" <> wrote in message
    > > > > > news:...
    > > > > > >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 = ""
    > > > > > > 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
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?UmljaCBSZWtvcw==?=, Jan 13, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter
    Replies:
    0
    Views:
    3,323
    Peter
    Jul 1, 2003
  2. Yossi Naggar

    Can't send html email message with asp.net

    Yossi Naggar, Jan 5, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    2,705
    Peter O'Reilly
    Jan 5, 2004
  3. Replies:
    2
    Views:
    373
    Tintin
    Jan 5, 2007
  4. Replies:
    13
    Views:
    434
    Randy Webb
    May 14, 2006
  5. Replies:
    2
    Views:
    81
    Richard Balbat
    Nov 12, 2013
Loading...

Share This Page