sending HTML email

Discussion in 'ASP .Net' started by =?Utf-8?B?SnVzdGlu?=, Nov 9, 2004.

  1. I have a fairly large piece of html, about 50 lines that I would like to send
    via an ASP.NET page I was wondering what would be the best and cleanest way
    to do this? Is there a way I can put the code in a WebControl or text file
    and pass that to Mailmessage.Body?

    Any suggestions would be great.

    Thanks, Justin.
    =?Utf-8?B?SnVzdGlu?=, Nov 9, 2004
    #1
    1. Advertising

  2. Justin, it depends more on how you want to maintain the text (e.g. from a
    text file, in the db, in a web control, etc.). All of these are doable. In a
    text file, I'd go (vb):

    public function GetMyText as string
    Dim fi As New System.IO.FileInfo(Server.MapPath("~\myText.txt"))
    Dim sr As System.IO.StreamReader = fi.OpenText()
    return sr.ReadToEnd
    end function

    then... mailmessage.body = GetMyText()

    If it's mostly static and you send a lot of them, you should also consider
    caching the text at the app level.

    hth,
    Bill

    "Justin" wrote:

    > I have a fairly large piece of html, about 50 lines that I would like to send
    > via an ASP.NET page I was wondering what would be the best and cleanest way
    > to do this? Is there a way I can put the code in a WebControl or text file
    > and pass that to Mailmessage.Body?
    >
    > Any suggestions would be great.
    >
    > Thanks, Justin.
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 9, 2004
    #2
    1. Advertising

  3. Can you recommend an article or tutorial that will help me develop user
    control that will hold the HTML? Or any other tutorials on sending HTML email
    with asp.net.

    Thanks, Justin.

    "Bill Borg" wrote:

    > Justin, it depends more on how you want to maintain the text (e.g. from a
    > text file, in the db, in a web control, etc.). All of these are doable. In a
    > text file, I'd go (vb):
    >
    > public function GetMyText as string
    > Dim fi As New System.IO.FileInfo(Server.MapPath("~\myText.txt"))
    > Dim sr As System.IO.StreamReader = fi.OpenText()
    > return sr.ReadToEnd
    > end function
    >
    > then... mailmessage.body = GetMyText()
    >
    > If it's mostly static and you send a lot of them, you should also consider
    > caching the text at the app level.
    >
    > hth,
    > Bill
    >
    > "Justin" wrote:
    >
    > > I have a fairly large piece of html, about 50 lines that I would like to send
    > > via an ASP.NET page I was wondering what would be the best and cleanest way
    > > to do this? Is there a way I can put the code in a WebControl or text file
    > > and pass that to Mailmessage.Body?
    > >
    > > Any suggestions would be great.
    > >
    > > Thanks, Justin.
    =?Utf-8?B?SnVzdGlu?=, Nov 10, 2004
    #3
  4. Several good ones from Scott Mitchell:

    http://aspnet.4guysfromrolla.com/articles/102203-1.aspx
    http://www.4guysfromrolla.com/webtech/080801-1.shtml

    Enjoy. As far as using a user control for what you're doing, I don't know
    the details, but doesn't seem to me like that's your best choice--it's extra
    complexity with no big bang. If you want to maintain the html externally, I'd
    use a text or xml file, or maybe the database. If you'd prefer to have it
    "baked in" somewhere, I'd just use a plain old constant string. Anyway, have
    fun.

    Bill

    "Justin" wrote:

    > Can you recommend an article or tutorial that will help me develop user
    > control that will hold the HTML? Or any other tutorials on sending HTML email
    > with asp.net.
    >
    > Thanks, Justin.
    >
    > "Bill Borg" wrote:
    >
    > > Justin, it depends more on how you want to maintain the text (e.g. from a
    > > text file, in the db, in a web control, etc.). All of these are doable. In a
    > > text file, I'd go (vb):
    > >
    > > public function GetMyText as string
    > > Dim fi As New System.IO.FileInfo(Server.MapPath("~\myText.txt"))
    > > Dim sr As System.IO.StreamReader = fi.OpenText()
    > > return sr.ReadToEnd
    > > end function
    > >
    > > then... mailmessage.body = GetMyText()
    > >
    > > If it's mostly static and you send a lot of them, you should also consider
    > > caching the text at the app level.
    > >
    > > hth,
    > > Bill
    > >
    > > "Justin" wrote:
    > >
    > > > I have a fairly large piece of html, about 50 lines that I would like to send
    > > > via an ASP.NET page I was wondering what would be the best and cleanest way
    > > > to do this? Is there a way I can put the code in a WebControl or text file
    > > > and pass that to Mailmessage.Body?
    > > >
    > > > Any suggestions would be great.
    > > >
    > > > Thanks, Justin.
    =?Utf-8?B?QmlsbCBCb3Jn?=, Nov 10, 2004
    #4
  5. =?Utf-8?B?SnVzdGlu?=

    Philipp Sumi Guest

    Philipp Sumi, Nov 20, 2004
    #5
    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. =?Utf-8?B?YmlkbGxj?=

    problem sending email in html format

    =?Utf-8?B?YmlkbGxj?=, Sep 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    535
    Hans Kesting
    Sep 28, 2004
  2. =?Utf-8?B?Vmk=?=

    Sending Email with HTML body

    =?Utf-8?B?Vmk=?=, Jan 18, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    528
    Karl Seguin [MVP]
    Jan 18, 2006
  3. Zsolt Koppany
    Replies:
    0
    Views:
    503
    Zsolt Koppany
    Nov 27, 2003
  4. Luke
    Replies:
    2
    Views:
    4,678
    Nigel Wade
    Mar 15, 2007
  5. rote
    Replies:
    8
    Views:
    752
Loading...

Share This Page