Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email current page?

Status
Not open for further replies.

sndkick

Programmer
Nov 1, 2000
71
US
I tried the search and looked a bit on the web but couldn't find anything satisfying out there.

What would you suggest as the best way to allow the user to send the current page to someone as an HTML email file? Granted lots of people cannot view HTML formatted emails, but I want the option anyway.

I want the user to be on a page and have a link they can click that will prompt them for the address to send the page to. Then when they click send, I want to retrieve the page they were on, and send it as the body of the email. I know how to send an email using ASP, and I know how to set it to send as HTML, but I can't figure out the best way to grab the page they were on, and then insert that page into the body of the email. I will also have to parse the page before inserting it, to replace all relative link & image paths with absolute paths.

Anyone have any good ideas on how to go about this?
 
You can use some ASP Email COM component, specify the
content type property so that you can send html email,
and add html source to the body text of each email.

 
sndkick,

You're on the right path. You're going to want to do that with CDONTS in ASP. Since you already know how to use that object and more importantly, write and send HTML mail, you're already about 90% of the way there.

Use the Request.ServerVariables("PATH_INFO") method to get the current page. This might get a little tricky because I'm betting that the page where they are entering the email address on (could be a small popup window or something like that) won't be the page that you want to email. So you're going to want to use that PATH_INFO method in the actual page that you want emailed and pass that value to the page that the user submits the email request.

Something like this..
Code:
<a href=&quot;emailreq.asp?P=<%=Request.ServerVariables(&quot;PATH_INFO&quot;)%>&quot;>Send this page to a Friend</a>

Then on the page where the user provides the email address, something like this.
Code:
<form>
  <input type=&quot;text&quot; name=&quot;email&quot;><br>
  <input type=&quot;submit&quot; value=&quot;Send&quot;>
  <input type=&quot;hidden&quot; name=&quot;pageinfo&quot; value=&quot;<%=Request.QueryString(&quot;P&quot;)%>&quot;>
</form>
Now, you'll need to do some fancy schmancy string handling on that PATH_INFO string because it will return the relative path in addition to the page name. But that shouldn't be too difficult.

Hope this helps.. :)

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top