|
I have a form that collects three date elements - the date, the month and the year; which are named txtDate, txtMonth and txtYear respectively.
I need these elements pasted into a URL in the resultant HTML email that is generated once `submit` is clicked; i.e.
http://intranet/reports/snapshot.asp?snapdate=01Jan03 (01 being txtDate, Jan being txtMonth and 03 being txtYear).
The entire ASP is as follows:
<%
`Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
Response.Buffer = True
`Dimension variables
Dim strBody `Holds the body of the e-mail
Dim objCDOMail `Holds the mail server object
Dim strMyEmailAddress `Holds your e-mail address
Dim strCCEmailAddress `Holds any carbon copy e-mail addresses
Dim strBCCEmailAddress `Holds any blind copy e-mail addresses
Dim strReturnEmailAddress `Holds the return e-mail address of the user
Dim strURL `URL for snapshot
strMyEmailAddress = "matt.ross@house.co.uk"
`----------- Place CC & BCC e-mail address`s in the following stings, separated by ; --------------
strCCEmailAddress = ""
`Read in the users e-mail address
strReturnEmailAddress = "house.co.uk intranet <intranet@house.co.uk>"
`Initialse strBody string with the body of the e-mail
strDay= Request.Form("txtDay")
strMo= Request.Form("txtMonth")
strYr = Request.Form("txtYear")
strURL = txtDay & txtMonth & txtYear
strBody = "<style type=text/css>body {font-family: verdana; font-size: 12px}</style>"
strBody = strBody & "<html>"
strBody = strBody & "<img src=`http://93.224.233.42/house/images/daily_snapshot/logos_lorry.gif`>"
strBody = strBody & "<br>"
strBody = strBody & "<img src=`http://93.224.233.42/house/images/daily_snapshot/main_pics.jpg`>"
strBody = strBody & "<body>"
strBody = strBody & "<br><br>"
strBody = strBody & "Dear House"
strBody = strBody & "<br><br>"
strBody = strBody & "The daily snapshot has been updated on the House intranet. "
strBody = strBody & "It includes data up to "
strBody = strBody & Request.Form("txtSnapDay") & " " & Request.Form("txtSnapMonth")
strBody = strBody & " " & Request.Form("txtSnapYear") & "."
strBody = strBody & "<br><br>"
strBody = strBody & "Please click the link below to view the latest information."
strBody = strBody & "<br><br>"
strBody = strBody & "<a href=`http://93.224.233.42/house/default.asp?main=cgi-bin/r-w/Snapshot/snapshot.asp?SnapDate=`& strURL>"
strBody = strBody & "<img src=`http://93.224.233.42/house/images/daily_snapshot/view_snapshot.gif` border=0></a>"
strBody = strBody & "<br><br>"
strBody = strBody & "Kind regards"
strBody = strBody & "<br><br>"
strBody = strBody & "Matt Ross"
strBody = strBody & "<br>"
strBody = strBody & "Intranet Development Manager"
strBody = strBody & "<br>"
strBody = strBody & "house.co.uk"
strBody = strBody & "<br><br>"
strBody = strBody & "t: 252866"
strBody = strBody & "<br>"
strBody = strBody & "e: <a href=`mailto:matt.ross@house.co.uk`>matt.ross@house.co.uk</a>"
strBody = strBody & "<br>"
strBody = strBody & "<a href=`http://house.co.uk`>http://house.co.uk</a><br>"
strBody = strBody & "<a href=`http://infonet/house`>http://infonet/house</a>"
`Send the e-mail
`Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
`Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = strReturnEmailAddress
`Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress
`Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress
`Set the subject of the e-mail
objCDOMail.Subject = "Customer Service Snapshot Updated"
`Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0
`Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0
`Set the main body of the e-mail
objCDOMail.Body = strBody
`Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1
`Send the e-mail
objCDOMail.Send
`Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<title>house.co.uk intranet - Daily Snapshot Email Notification</title>
<link rel="stylesheet" href="/styles/HouseDefault.css" type="text/css">
</head>
<body>
<h3>house.co.uk intranet - Customer Service Snapshot Email Notification</h3>
<p>Thank you, the Customer Service Snapshot email has been sent to Z House.
<% Dim pageOwnerName
pageOwnerName = "Matt Ross" %>
<!--#include virtual="\house\_codelib\pageFooter.inc"-->
</body>
</html>
Unfortunately the link ends at snapdate= and doesn`t include the date whatsoever. Anyone able to assist with this?
Thanks
Matt
|
|
|
You are going to feel like an idiot I`m afraid! The problem is right here:
strDay= Request.Form("txtDay")
strMo= Request.Form("txtMonth")
strYr = Request.Form("txtYear")
strURL = txtDay & txtMonth & txtYear
This last line is incorrect, it should be:
strURL = strDay & strMo & strYr
Simple mistake. There you go!
|
|
|
|
|
By the way, I don`t know what is the standard methodology, but I always name my VBScript variable names EXACTLY the same as my HTML Form Element names. Otherwise, I run into problems like you just had. If the form element name is "FirstName", then my VBScript var name is "FirstName"
FirstName = Request.Form("FirstName")
Also, I make the database column name exactly the same.
Select FirstName from Employee .....
FirstName = rs.Fields("FirstName")
This keeps me from messing up the variable names and allows me to use copy and paste to speed things up. For example, once I create my database reads like:
FirstName = rs.Fields("FirstName")
LastName = rs.Fields("LastName")
Email = rs.Fields("Email")
Then for my form read, I can just copy and paste the above, then do a replace of "rs.Fields" with "Request.Form". See?
Also, I almost never name my vars using the type prefix such as "str" and "int" -- but I think that is a good practice--I`m just lazy that way!
|
|
|
|
|
|
|
|
|
|