•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 423,949 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,214 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1616 | Replies: 3
![]() |
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:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks guys :mrgreen:
<%
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> & "<http://www.ThemePics.co.uk/" & 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:
Last edited by MaxMumford : Dec 8th, 2006 at 3:21 am.
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Most probably you are getting the URL of the page where this script placed! If yes so, You can use the hidden field in the form to store the URL then use the into asp script
you can add this line in html form,
and this in asp script
Example : http://www.katarey.com/forHelp/2a.asp
I hope this will helpful for you
Best Regards,
Rahul
you can add this line in html form,
<input name="urlHolder" type="hidden" id="urlHolder" value="<%=Request.ServerVariables("URL")%>">and this in asp script
Dim urlHolder 'Holds The URL of the Page Where the HTML form is
urlHolder = request.form("urlHolder")strBody = request.form("yname")
strBody = strBody & "<h2> has seen a picture they liked, and thought you would like to!</h2>"
strBody = strBody & "<br><u>Below is a comment that they wrote for you:</u><br>"
strBody = strBody & "<b><u>Message:</u></b>" & request.form("message")
strBody = strBody & "<br><a href='http://www.ThemePics.co.uk/" & urlHolder &"'>"
strBody = strBody & "http://www.ThemePics.co.uk/" & urlHolder & "</a>"Example : http://www.katarey.com/forHelp/2a.asp
I hope this will helpful for you
Best Regards,
Rahul
Last edited by katarey : Dec 8th, 2006 at 5:03 am.
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
and you can also use this :
Complete Code :
in this Example you don’t need to change in your html form
request.servervariables("HTTP_REFERER")
Instead of
Request.ServerVariables("URL")
Complete Code :
<%
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")
strBody = strBody & "<h2> has seen a picture they liked, and thought you would like to!</h2>"
strBody = strBody & "<br><u>Below is a comment that they wrote for you:</u><br>"
strBody = strBody & "<b><u>Message:</u></b>" & request.form("message")
strBody = strBody & "<br><a href='" & request.servervariables("HTTP_REFERER") &"'>"
strBody = strBody & request.servervariables("HTTP_REFERER") & "</a>"
'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
%>in this Example you don’t need to change in your html form
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
tnx for all the help. works perfectly
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Jmail with radio buttons and menus (Site Layout and Usability)
- asp form action script (Site Layout and Usability)
Other Threads in the ASP Forum
- Previous Thread: ASP and JavaScript working together
- Next Thread: Need help…any suggestions


Linear Mode