Image and Stylesheet References in HTML Email

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2aWQ=?=, Jun 27, 2007.

  1. Hi all,

    I need to generate an HTML email message that is sent to internal customers.
    Rather than build the message as a string in my code, I have developed a web
    page I want to send as the body of the message. I'm using the httpWebRequest
    and httpWebResponse objects retrieve the contents of the page, but the images
    and stylesheets both use relative addresses that include the tilde
    (~/Images/Image.gif). I would like the tilde to be changed to an absolute
    uri like http://Server/Site/Images/Image.gif, but I haven't figured out a way
    to do it. I have found code to actually attach the images to the email, but
    I'd rather use references like the big boys do, such as Microsoft's
    newsletters. Surely there are others who have done something like this.
    Does anyone have any suggestions?

    Thanks,

    David
    =?Utf-8?B?RGF2aWQ=?=, Jun 27, 2007
    #1
    1. Advertising

  2. On Jun 27, 3:28 pm, David <> wrote:
    > Hi all,
    >
    > I need to generate an HTML email message that is sent to internal customers.
    > Rather than build the message as a string in my code, I have developed a web
    > page I want to send as the body of the message. I'm using the httpWebRequest
    > and httpWebResponse objects retrieve the contents of the page, but the images
    > and stylesheets both use relative addresses that include the tilde
    > (~/Images/Image.gif). I would like the tilde to be changed to an absolute
    > uri likehttp://Server/Site/Images/Image.gif, but I haven't figured out a way
    > to do it. I have found code to actually attach the images to the email, but
    > I'd rather use references like the big boys do, such as Microsoft's
    > newsletters. Surely there are others who have done something like this.
    > Does anyone have any suggestions?
    >


    Hi David

    try this code

    Uri u = HttpContext.Current.Request.Url;
    string i = "/Images/Image.gif";
    Uri a = new Uri(u, i);

    CSS also could be included in the HTML code using <style></style>

    Hope it helps
    Alexey Smirnov, Jun 27, 2007
    #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. Replies:
    3
    Views:
    510
    AdamM
    Jul 27, 2004
  2. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    558
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  3. Steven An
    Replies:
    1
    Views:
    487
    Martin Honnen
    Nov 23, 2004
  4. David Blickstein
    Replies:
    3
    Views:
    1,020
    David Blickstein
    Aug 2, 2005
  5. David Blickstein
    Replies:
    14
    Views:
    6,298
    Harrie
    Oct 16, 2005
Loading...

Share This Page