471,592 Members | 1,230 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,592 software developers and data experts.

Inserting a dynamic URL in to a MAILTO: tag

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
Nov 19 '05 #1
6 7219
35th Ave Media < na@na.na > wrote:
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.
Nov 19 '05 #2
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:ex*****@e-mail.com?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/de...temwebmail.asp

ASP
Read up on the CDONTS objects focusing on the NewMail object.
http://msdn.microsoft.com/library/de...ts_library.asp

--
HTH
Dave Fancher
http://davefancher.blogspot.com
"Jeff Evans" <jwevans1@you_eye_you_see.edu> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
35th Ave Media < na@na.na > wrote:
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.

Nov 19 '05 #3
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

Dave Fancher wrote:
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:ex*****@e-mail.com?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/de...temwebmail.asp

ASP
Read up on the CDONTS objects focusing on the NewMail object.
http://msdn.microsoft.com/library/de...ts_library.asp

Nov 19 '05 #4
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
--
Dave Fancher
http://davefancher.blogspot.com
"35th Ave Media" <na@na.na> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
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

Dave Fancher wrote:
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:ex*****@e-mail.com?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/de...temwebmail.asp

ASP
Read up on the CDONTS objects focusing on the NewMail object.
http://msdn.microsoft.com/library/de...ts_library.asp

Nov 19 '05 #5
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
Dave Fancher wrote:
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

Nov 19 '05 #6
No problem, glad I could be of service.

--
Dave Fancher
http://davefancher.blogspot.com
"35th Ave Media" <na@na.na> wrote in message
news:u9**************@TK2MSFTNGP12.phx.gbl...
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
Dave Fancher wrote:
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

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by John Pether (john | last post: by
2 posts views Thread by collinm | last post: by
3 posts views Thread by sferriol | last post: by
2 posts views Thread by Slain | last post: by
reply views Thread by Edwin.Madari | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.