List Info

Thread: Emailing a dynamic webpage




Emailing a dynamic webpage
user name
2006-06-15 16:42:20
Sure.
It would involve a separate processing page somewhere under
your webroot
(let's say "/tools/email_page.cfm").

This processing page, in it's simplest form, would look
something like:

<html>
   :

<body>

<cfif IsDefined("FORM") AND
StructKeyExists(FORM,"emailUrl")>
	<!--- the user has filled in the form --->

	<!--- probably should wrap a lot of this in a CFTRY for
error
handling --->
	<cfhttp method="post"
url="#FORM.emailUrl#"
resolveurl="true"
result="strHttpPage" ... (proxy settings, etc,
if needed)>
		<!---
                  if you want to access secure pages,
you'll probably
want to do a POST if you 
                  need to send along the user's cookie
information or
other headers
			otherwise, you could just do cfhttp with a
method="get" 
		--->
		<cfloop collection="#COOKIE#"
item="whichCookie">
			<cfhttpparam type="cookie"
name="#whichCookie#"
value="#COOKIE[whichCookie]#" ...>
		</cfloop>
	</chttp>
	 

	<cfif
StructKeyExists(strHttpPage.responseHeader,"status_cod
e")
AND strHttpPage.responseHeader.status_code = 200>
		<cfmail to="#FORM.emailTo#" ...     
Type="html" >
			<p>Dear #FORM.nameTo#,</p>
			<p>Your collegue, #FORM.nameFrom# sent you the
following page as a reference.</p>
			<p>#FORM.emailComments#</p>

			#strHttpPagefileContent#
		</cfmail>
		<p>Your email has been sent</p>
	<cfelse>
		<p>Sorry, your email could not be sent.</p>
	</cfif>

<cfelse>
	<!--- the user has just arrived at the pop-up (from a
page), and
still needs 
            to fill out the form --->
	<cfif StructKeyExists(URL,page)>
		<form action="#CGI.script_name#"
method="post" ...>
		<p>
		Who would you like to send this page to?<br />

		Name: <input type="text"
name="nameTo"><br />
		Email: <input type="text"
name="emailTo"><br />
		</p>

		<p>
		Who should we say it's from?<br />
		Name: <input type="text"
name="nameFrom"><br />
		Email: <input type="text"
name="emailFrom"><br />
		</p>

		<p>
		Comments<br />
		<textarea name="emailComments"
...><br />
		</p>

		<input type="hidden"
name="emailUrl"
value="#URLDecode(URL.page)#" ...>
		<input type="submit" ...>
		
		</form>
	<cfelse>
		<p>Sorry, there was a problem.</p>
	</cfif>
</cfif>

</body>

</html>


Then you call the processing page client-side via
javascript, or you
could do it server-side via ColdFusion. There are pros and
cons of each
method. With javascript, you, of course, are relying on the
fact that
the user would have javascript-enabled. With ColdFusion, it
would mean
you'd have to build the link via a custom script (in
Commonspot). But
building the link in ColdFusion is pretty trivial.

<cfscript>
	sPagePath = Trim(CGI.script_name) & "?"
&
Trim(CGI.query_string);
	sPagePath = URLEncodedFormat(sPagePath);
</cfscript>
<cfoutput>
      <!--- could also be a javascript openWin function
to set the
pop-up size, etc --->
	<a href="/tools/email_page.cfm?page=#sPagePath
#">Email this
page</a>
</cfoutput>

Of course... All this comes with the caveat that the
receiving party
will have varying success viewing the email depending on
what code is
actually in your  page, and the email client they're using.

You can also expand the above to use a CFDOCUMENT tag to
email the page
as a PDF or whatever.


-Carl Steinhilber
 Mentor Graphics Corp
 www.mentor.com

 

-----Original Message-----
From: commonspot-bounceschattyfig.figleaf.com
[mailto:commonspot-bounceschattyfig.figleaf.com] On
Behalf Of Scott
Twitchell
Sent: Thursday, June 15, 2006 7:33 AM
To: commonspotchattyfig.figleaf.com
Subject: [Commonspot] Emailing a dynamic webpage

All,
	We are looking to be able to allow users to send a
CommonSpot
page in an email. We want to put an "Email this
Page" link on either a
static CS page or a dynamically generated CS page, have the
user
prompted to enter a subject, and a 'to' email address and
have the
currently displayed page emailed to the 'to' address. 
Some of these
pages require authentication, so just sending the link
won't suffice.

Has anyone done something like this?

Scott

_______________________________________________
Commonspotchattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/commonspot


Brought to you by Fig Leaf Software
Premier Authorized Paperthin Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
_______________________________________________
Commonspotchattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/commonspot


Brought to you by Fig Leaf Software
Premier Authorized Paperthin Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )