Send til en ven via CDONTS
Jeg har et problem med at få et "Send til ven" script til at virke. Er der nogle der gidder at prøve at køre det for at se hvad der er galt. Det skal siges at CDONTS komponenten er installeret på en Windows 2000 server og jeg bruger mail komponenten i andre tilfælde og der virker det fint. Jeg bliver nødt til at sende koden med til tre filer som blot kan kopieres for at teste dette script. På forhånd tak for hjælpen.<b>cdonts.asp</b> (side 1 - indeholder blot et link )
<html><head><title>test</title></head>
<body>
<a href="test.asp?name=mugge&gender=male">videre</a>
</body>
</html>
<b>test.asp</b> (modtager querystring og åbner nyt vindue)
<%
link = request.querystring
%>
<html>
<head>
<title>Test</title>
<script language="javascript">
function TellFriend(ref)
{
var str="toolbar=no,status=no,menubar=no,location=no,scrollbars=no,resizable=no,height=300,width=450"
tellaFriend = window.open(ref,"TellObj",str);
tellaFriend.opener = top;
}
</script>
</head>
<body>
<font face="Verdana,Times New Roman,Georgia,Times"><font size="1"><a href="java script:TellFriend('http://localhost/anbefal/tellafriend.asp?page=<%=server.URLEncode("test.asp?"&link&"")%>')">Tell a friend/colleague</a></font>
</body>
</html>
<b>tellafriend.asp</b> (her det sner og her det går galt)
<HTML>
<HEAD>
<TITLE>JustATest - Tell a Friend</TITLE>
<BR>
<%
page=""
qs=Request.ServerVariables("query_string")
if len(qs)>0 then
page=right(qs, len(qs)-5)
end if
if page="" then
page=Request.form("page")
if page="" then
Response.Write "Error1"
Response.End
end if
end if
if Request.Form("fromEmail")="" then
showForm
else
sendEmail
end if
sub showForm
%>
<HTML>
<HEAD>
<TITLE>JustATest - Tell a Friend/coll</TITLE>
<script language="JavaScript">
<!--
window.focus();
// -->
</script>
</HEAD>
<body bgcolor="#FFFFFF" link="#003399"
alink="#FF3366" vlink="#003399" text="#000000" cellspacing="0" cellpadding="0">
<table border=0 cellpadding=5 cellspacing=5 width=95% >
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#2E3092">
<tr>
<td><font face="verdana, arial"
size="2" color=white> <b>Tell a friend/colleague</b></font></td>
</tr>
<tr>
<td>
<table border=0 cellpadding=5 cellspacing=0 width=100% bgcolor="#ffffff">
<tr>
<td valign="top">
<font face="verdana, arial" size="1">
Use the form below to send your
friend/colleugue an e-mail telling him/her about this page
(we <b>do not</b> store
the email addresses and will <B>never</b>
contact you using email addresses entered only in tell-a-friend/colleague)
</font></td>
</tr>
<TR>
<td>
<table border=0 cellpadding=0 cellspacing=0>
<TR>
<td align="left">
<form action="tellafriend.asp" method="POST">
<font face="verdana, arial" size="2">
<nobr>Your e-mail: </nobr>
</font></td>
<td align="left">
<input type="Text" name="fromEmail"
value="" size="32" maxlength="255">
</TD>
</tr>
<TR>
<td align="left">
<font face="verdana, arial" size="2">
<nobr>Your friend's e-mail: </nobr>
</font></td>
<td align="left">
<input type="Text" name="toEmail"
value="" size="32" maxlength="255">
</TD>
</tr>
<TR>
<td align="left" valign=top>
<font face="verdana, arial" size="2">
<nobr>Additional Message: </nobr>
</font></td>
<td align="left">
<textarea name=message maxlength=500
cols=24 rows=5></textarea>
</td>
</tr>
<TR><td height="5" colspan="2"></td></tr>
<TR>
<td></td>
<td align="left" valign="top">
<input type="hidden" name="page" value="<%=page%>">
<input type="Submit" value="Send It"></td></tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<p>
</BODY>
</HTML>
<%
end sub
sub sendEmail
fromEmail=Request.Form("fromEmail")
toEmail=Request.Form("toEmail")
message=Request.Form("message")
page=Request.Form("page")
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = fromEmail
objNewMail.To = toEmail
objNewMail.Subject = "From JustAtest's homepage - tell a friend/colleague"
strBody = "Hi,"&Vbcrlf&Vbcrlf
strBody=strBody & fromEmail &" asked us to forward a message to you because "
strBody=strBody & "he/she thought you might be interested in the following "
strBody=strBody & "information "&vbcrlf&vbcrlf&page&vbcrlf&vbcrlf
strBody=strBody&"__________________________________________"&vbcrlf&Vbcrlf
strBody=strBody& fromEmail & " wrote : " &vbcrlf&Vbcrlf
strBody=strBody&message&vbcrlf&vbcrlf
strBody=strBody&"__________________________________________"&vbcrlf
strBody=strBody&"JustAFriend"&vbcrlf
strBody=strBody&"http://www.JustATest.dk"
objNewMail.Body=strBody
objNewMail.Send
Set objNewMail = Nothing
%>
<html>
<body bgcolor="#FFFFFF" link="#003399"
alink="#FF3366" vlink="#003399" text="#000000" cellspacing="0" cellpadding="0">
<table border=0 cellpadding=5 cellspacing=5 width=95% >
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#2E3092">
<tr>
<td><font face="verdana, arial" size="2" color="white"> <b>
Tell a Friend</b></font></td>
</tr>
<tr>
<td>
<table border=0 cellpadding=5 cellspacing=0 width=100% bgcolor="#ffffff">
<tr>
<td align="left" valign=top>
<font face="verdana, arial, helvetica" SIZE="2">
Thanks! An e-mail has been sent to <b><%=toEmail%></b>
telling him/her about this page.
<p>
<b>Note: </b>This message is not a guarantee of delivery.
<p>
• <a href="java script:window.close()">Close this window</a>
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
</BODY>
</HTML>
<%
end sub%>
