Sending Email with HTML body

Discussion in 'ASP .Net' started by =?Utf-8?B?Vmk=?=, Jan 18, 2006.

  1. Hi,
    Is there a simple way to send an email from ASP.NET using the MailMessage
    class with MyMessage.BodyFormat = MailFormat.Html, such that the body of the
    email will come from an existing HTML file?

    All the examples I was able to find have something like this:
    string strBody = "<html><body><b>Hello World</b>" +
    " <font color=\"red\">ASP.NET</font></body></html>";
    MyMessage.Body = strBody;

    But I want the content to come directly from an existing HTML file.
    Thanks in advance.
     
    =?Utf-8?B?Vmk=?=, Jan 18, 2006
    #1
    1. Advertising

  2. If this is a pure .html file, you can simply open it via the StreamReader.

    dim sr as StreamReader
    try
    sr = new StreamReader("myFile.html")
    dim content as string = sr.ReadToEnd()
    MyMessage.Body = content
    finally
    if not sr is nothing then
    sr.close()
    end if
    end try

    --
    http://www.openmymind.net/



    "Vi" <> wrote in message
    news:...
    > Hi,
    > Is there a simple way to send an email from ASP.NET using the MailMessage
    > class with MyMessage.BodyFormat = MailFormat.Html, such that the body of
    > the
    > email will come from an existing HTML file?
    >
    > All the examples I was able to find have something like this:
    > string strBody = "<html><body><b>Hello World</b>" +
    > " <font color=\"red\">ASP.NET</font></body></html>";
    > MyMessage.Body = strBody;
    >
    > But I want the content to come directly from an existing HTML file.
    > Thanks in advance.
    >
     
    Karl Seguin [MVP], Jan 18, 2006
    #2
    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. Steve D. Perkins

    JavaMail sending email with no body content

    Steve D. Perkins, Dec 8, 2004, in forum: Java
    Replies:
    1
    Views:
    3,630
    Graeme Hill
    Dec 8, 2004
  2. Kun
    Replies:
    1
    Views:
    281
    Jesse Hager
    Apr 16, 2006
  3. Luke
    Replies:
    2
    Views:
    4,753
    Nigel Wade
    Mar 15, 2007
  4. johnny15
    Replies:
    0
    Views:
    592
    johnny15
    May 17, 2007
  5. Jason Pfeifer
    Replies:
    1
    Views:
    132
    Logan Capaldo
    Jan 23, 2006
Loading...

Share This Page