Inserting a dynamic URL in to a MAILTO: tag

3

35th Ave Media

Hello,

I have about 60+ pages that I need to insert a MAILTO: tag so people can
email the page using their email client. The body of the message is
going to be the URL of that page. Using ASP, how can I insert the page
URL in the email body without having to manually enter each URL for each
MAILTO: tag? Is there a variable that can be used inside the MAILTO: tag
that automatically inserts the current page's URL into the body of the
email?

Thank you in advance,

JWA
 
J

Jeff Evans

35th Ave Media said:
I have about 60+ pages that I need to insert a MAILTO: tag so people can
email the page using their email client. The body of the message is going
to be the URL of that page. Using ASP, how can I insert the page URL in
the email body without having to manually enter each URL for each MAILTO:
tag? Is there a variable that can be used inside the MAILTO: tag that
automatically inserts the current page's URL into the body of the email?


Check out the Request object - there should be something there you can use,
likely:

HttpContext.Current.Request.Url

There are also some other properties in Request that might work if Url isn't
exactly right. HTH.
 
D

Dave Fancher

I'm not sure if this will work on mail clients other than Outlook (I haven't
tried it) but for some simple tasks, I've just done the following:

<a
href="mailto:[email protected]?subject=Check%20This%20Out!&body=http://www.microsoft.com">E-Mail</a>

Another thing you could do is consider handling the dynamic build of an
e-mail message server side. Your post said ASP and although this is an
ASP.NET news group, I'll post the solutions for both.

ASP.NET
Read up on the classes located in System.Web.Mail paying particular
attention to the SmtpServer and MailMessage classes.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebmail.asp

ASP
Read up on the CDONTS objects focusing on the NewMail object.
http://msdn.microsoft.com/library/d...n-us/cdo/html/_denali_cdo_for_nts_library.asp
 
3

35th Ave Media

Please forgive my ingnorance of not knowing much more than HTML.

Your reference came in handy. Thank you for the help.

Now another question:
I have two pages: 1) The form page for submitting the form 2) The form
processor page that processes the information from the form and emails
the info.

Example:

1. User clicks link (Email this page)
2. A browser window opens with the form page (formpage.asp) for the
user to fill out their email address etc.
3. User submits form then the data is processed by formpage_process.asp
and the email is created and mailed off to the
recipient.

What I would like to do is have the page TITLE and URL, where the "Email
this page" link is placed, to be inserted into the email body. How do I
transfer the TITLE and URL over the the formpage.asp to be displayed on
the form page AND then have it passed to the formpage_process.asp to be
inserted into the body of the email?

I can work out the part for displaying it in the email body, but I have
no idea how to grab the TITLE and URL and pass it to both pages.

Let me know if I should paste the code I have.

Thank you for your help,

JWA
 
D

Dave Fancher

Since you're using traditional ASP I'd recommend posting future questions to
microsoft.public.inetserver.asp (or a similar group) if you haven't done so
already (I didn't look) but we can finish this one here ;)

To get the values to your form, you'll have to put them into the querystring
portion of the link. You'll probably have to define the page title as a
variable so you can use it in both <TITLE> and in your link. The URL will
be a bit easier.

(All code is in JavaScript)

<%
var title = "Page Title";
%>
....
<TITLE><%= title %></TITLE>
....
<A href="formpage.asp?title=<%= title %>&url=<%=
Request.ServerVariables("HTTP_URL") %>">E-Mail This Page</a>

As for retrieving these values on formpage.asp, you'll have to use the
following:
<%
var title = Request.QueryString("title");
var url = Request.QueryString("url");
%>

Depending on how you lay out your form you have a few options:

1.) Title and URL simply displayed in the body of the page.
Just reference the variable <%= title %> or <%= url %>
AND
include hidden fields in the form <input type="hidden" name="title"
value="<%= title %>"> (same concept for URL)

2.) Displayed in text fields.
<input type="text" name="title" value="<%= title %>"> (same concept for URL)

3.) If you're allowing your users to enter a custom body in addition to the
title and URL and you want to include these in the body text box.
<textarea id="msgBody">
<%= title %><%= url %>
</textarea>

When the form is submitted, the field names will be accessible from the
Request.Form collection in formpage_process.asp.
<%
// Include these lines as needed depending on which method you use.
var title = Request.Form("title");
var url = Request.Form("url");
var msgBody = Request.Form("msgBody");

...
// You can then build your message body by concatenating the strings
together.
var mailBody = title + "\n" + url + "\n" + msgBody;
...
%>

HTH
 
3

35th Ave Media

Hey Dave,

Thank you for your help. You made my life much easier - not to mention I
learned quite a bit from you example.

James
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top