Image and Stylesheet References in HTML Email

G

Guest

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
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top