Hi all, im trying to make a script which sends the link of the page to a specified email address. I have made it work by using a script from an external file, but when i call up the server variable request url, ht gets the wrong one, so i put the script in the same page as the page that needs to be called up in the email. The script is kinda complicated (for me - i am self tought) and could sombody tell me what im doing wrong? here it is:
<%
Response.Buffer = True
'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objJMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strSMTPServerAddress 'Holds the SMTP Server address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
'----------------- Place your e-mail address in the following sting ---------------------------------
strMyEmailAddress = request.form("femail")
'---------- Place the address of the SMTP server you are using in the following sting ---------------
strSMTPServerAddress = "smtp.ntlworld.com"
'-------------------- Place Carbon Copy e-mail address in the following sting ------------------------
strCCEmailAddress = request.form("yemail") 'Use this string only if you want to send the carbon copies of the e-mail
'-------------------- Place Blind Copy e-mail address in the following sting -------------------------
strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail
'-----------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("yemail")
'Initialse strBody string with the body of the e-mail
strBody = request.form("yname") & "<h2> has seen a picture they liked, and thought you would like to!</h2>" & <br> "<u>Below is a comment that they wrote for you:</u>" <br> & "<b><u>Message:</u></b>" & request.form("message")<br> & "<[URL]http://www.ThemePics.co.uk/[/URL]" & Request.ServerVariables("URL")
'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If
'Send the e-mail
'Create the e-mail server object
Set objJMail = Server.CreateObject("JMail.SMTPMail")
'Out going SMTP mail server address
objJMail.ServerAddress = strSMTPServerAddress
'Senders email address
objJMail.Sender = strReturnEmailAddress
'Senders name
objJMail.SenderName = Request.Form("yName")
'Who the email is sent to
objJMail.AddRecipient strMyEmailAddress
'Who the carbon copies are sent to
objJMail.AddRecipientCC strCCEmailAddress
'Who the blind copies are sent to
objJMail.AddRecipientBCC strBCCEmailAddress
'Set the subject of the e-mail
objJMail.Subject = request.form("yname")&" has invited you to view this picture!"
'Set the main body of the e-mail (HTML format)
objJMail.HTMLBody = strBody
'Set the main body of the e-mail (Plain Text format)
'objJMail.Body = strBody
'Importance of the e-mail ( 1 - highest priority, 3 - normal, 5 - lowest)
objJMail.Priority = 3
'Send the e-mail
objJMail.Execute
'Close the server object
Set objJMail = Nothing
%>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks guys :mrgreen: