Email this page to a friend

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

what is the code i must use to "email a webpage to a friend." Also, where can
I find the icon to use for that? thanks for helping out this new kid on the
block. I am using frontpage 2003.
 
Assuming you have a Windows Web server, try the page
below. You'll have to change the FromAddr and MailServ
values to those of your address and your mail server.

<%option explicit%>
<html>
<head>
<title>Mail Referring Web Page</title>
</head>
<body>
<%
Const FromAddr = "(e-mail address removed)"
Const MailServ = "smtp.example.com"
Const cdoSchema = _
"http://schemas.microsoft.com/cdo/configuration/"
dim refpage
dim address
dim objMsg
If "" & request("btnSub") = "" Then
refpage = "" & request.servervariables("HTTP_REFERER")
else
refpage = trim("" & Request.Form("refpage"))
address = trim("" & Request.Form("txtAddr"))
If refpage = "" Then
Response.Write "<p>Message not sent: " & _
"URL missing.</p>" & vbCrLf
Elseif address = "" Then
Response.Write "<p>Message not sent: " & _
"To Address missing.</p>" & vbCrLf
Else
Set objMsg = CreateObject("CDO.Message")
objMsg.Subject = "Web page at: " & refpage
objMsg.Sender = FromAddr
objMsg.To = address
objMsg.CreateMHTMLBody(refpage)
objMsg.Configuration.Fields.Item( _
cdoSchema & "sendusing") = 2
objMsg.Configuration.Fields.Item( _
cdoSchema & "smtpserver") = MailServ
objMsg.Configuration.Fields.Item( _
cdoSchema & "smtpserverport") = 25
objMsg.Configuration.Fields.Update
objMsg.Send
Response.Write "<p>Message sent.</p>" & vbCrLf
End If
End If
%>
<form method="POST">
<input type="hidden" name="refpage"
value="<%=refpage%>">
<table border="0">
<tr>
<td>Send page:</td>
<td><%=refpage%></td>
</tr>
<tr>
<td>To Address::</td>
<td><input type="text" name="txtAddr" size="40"
value="<%=address%>"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="Submit"
name="btnSub"></td>
</tr>
</table>
</form>
</body>
</html>

If you saved this page as mailpage.asp, you would link to
it as:

<a href="mailpage.asp">Mail this page to a friend.</a>

Also, keep in mind that some of the fancy stuff that
works in a browser (like DHTML menus and forms) won't
work in a mail program.

For more info about the e-mail techniques in this page,
browse:

Mailing Form Data
http://www.interlacken.com/winnt/tips/tipshow.aspx?tip=46

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 

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

Back
Top