amirlol
Well-Known Member
کد:
<!--#include file="tellafriend.asp"-->
------------------------
<%
dim site, strsmtp, ShowAction
site = Request.ServerVariables("SERVER_NAME")
'This allows you to test on your local system and move to your host server 'and not have to change the smtp everytime
if site = "localhost" then
strsmtp = "127.0.0.1"
elseif site = "www.yourdomain.com" then
strsmtp = "mail.yourdomain.com"
end if
ShowAction = Request.QueryString("action")
Select Case ShowAction
Case ""
%>
<form action="tellafriend.asp?action=send" method="post">
<B><font size="2"> Email a Friend about ASP Basic</font><B><BR>
<input type="text" name="email" size="25" maxlength="50" value="" onFocus="doClear(this)"><BR>
<center><input height="1px" type="submit" name="submit" value="Tell a friend"></center>
</form>
<%
Case "send"
if request.form("email") <> "" then
'sets variables
dim email, sendmail
email = request.form("email")
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
' Outgoing SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strsmtp
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'send a specific page or send a site url
dim url
'url = Request.ServerVariables("HTTP_REFERER")
url = "http://www.yourdomain.com/"
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "[email protected]"
objCDOSYSMail.To = email
objCDOSYSMail.Subject = "Check out this website - http://www.yourdomain.com/"
objCDOSYSMail.HTMLBODY = "Site recommendation from a friend!<br><br>" & _
vbCrlf & vbCrlf & "A friend has sent you this email and recommends you check out the site at " & _
vbCrlf & "<a href=""http://www.yourdomain.com"">ASP Basic - ASP Scripts</a> at " & _
vbCrlf & url & vbCrlf & _
vbCrlf & "<br><br>" & _
vbCrlf & "Thank you<br><br>" & _
vbCrlf & "[email protected]" & vbCrlf
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
response.redirect Request.ServerVariables("HTTP_REFERER")
else
response.redirect Request.ServerVariables("HTTP_REFERER")
end if
end select
%>