• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Syntax Error

Ok i have this script:

********************************8
<% @LANGUAGE="VBSCRIPT" CODEPAGE="1252" %>

<!--#include virtual="/includes/connection_string.asp"-->

<%
PropertyID = Clng(Request.QueryString("ID"))

Set RS = Server.CreateObject("ADODB.Recordset")
PropertySQL = "SELECT * FROM tblProperty WHERE ID=" & PropertyID
RS.Open PropertySQL, Connection

PropertyName = RS("txtPropertyTitle")
OwnerID = RS("intUserID")

RS.Close
Set RS = Nothing

Set RS = Server.CreateObject("ADODB.Recordset")
OwnerSQL = "SELECT * FROM tblUsers WHERE ID=" & OwnerID
RS.Open OwnerSQL, Connection

OwnerEmail = RS("txtEmailAddress")
OwnerName = RS("txtFirstName") & " " & RS("txtLastName")

RS.Close
Set RS = Nothing

Response.Write OwnerName
Response.Write "<br>"
Response.Write OwnerEmail
Response.Write "<br>"
Response.Write PropertyName

Set Mail = Server.CreateObject("SMTPsvg.Mailer")

Mail.FromName   = Request.Form("name")
Mail.FromAddress= Request.Form("email")
Mail.RemoteHost = "mrvnet.kundenserver.de"
Mail.AddRecipient OwnerName, OwnerEmail
Mail.Subject    = "Sunshine Escape Enquiry: " & PropertyName
Mail.BodyText   = Request.Form("bodytext") & VbCrLf & VbCrLf & "- - - - BOOKING DETAILS - - - -" & VbCrLf & "Booking Date From: " & Request.Form("FromDay") & " " & Request.Form("FromMonth") & " " & Request.Form("FromYear") & VbCrLf & "Booking Date To: " & Request.Form("ToDay") & " " & Request.Form("ToMonth") & " " & Request.Form("ToYear") & VbCrLf & "No. Of People: " & Request.Form("NumPeople")

Set Mail = Nothing
Set Connection = Nothing
%>

<p>Your message has been successfully sent, you should recieve a reply within two
working days.</p>>
<a href="/default.asp">Return <<</a>
*************************************************

This script above does not fail with an error or anything like that, it just displays the html "Your message has been succes........" , but i do not recieve the email!

This script however does work...
**************************************************
<% @LANGUAGE="VBSCRIPT" CODEPAGE="1252" %>

<%
Set Mail = Server.CreateObject("SMTPsvg.Mailer")

Mail.FromName   = Request.Form("name")
Mail.FromAddress= Request.Form("email")
Mail.RemoteHost = "mrvnet.kundenserver.de"
Mail.AddRecipient "Carl", "carl@rico-chet.co.uk"
Mail.Subject    = "Site Enquiry: "
Mail.BodyText   = Request.Form("bodytext") & VbCrLf & VbCrLf & "- - - - BOOKING DETAILS - - - -" & VbCrLf & "Booking Date From: " & Request.Form("FromDay") & " " & Request.Form("FromMonth") & " " & Request.Form("FromYear") & VbCrLf & "Booking Date To: " & Request.Form("ToDay") & " " & Request.Form("ToMonth") & " " & Request.Form("ToYear") & VbCrLf & "No. Of People: " & Request.Form("NumPeople")

Set Mail = Nothing
%>

<p>Your message has been successfully sent, you should recieve a reply within two
working days.</p>>
<a href="/default.asp">Return <<</a>
***************************************************

so its not an issue with the functionality of the ASPmail compnent from 1and1 as that script DOES work flawlessly.

Back to the 1st script then......The section where i have put in:
Response.Write OwnerName
Response.Write "<br>"
Response.Write OwnerEmail
Response.Write "<br>"
Response.Write PropertyName
Displays all the correct data in three lines so the databse connection is all ok and the sql is all ok and the variables are being set correctly, this is not the issue.

All the fields are Mail.***** are all ok as they work with the static script.....SO,  the only thing it can be is the syntax of when i am placing the variables in the Mail.***** part of the script.

I have tried:
Mail.AddRecipient OwnerName, OwnerEmail
Mail.Subject    = "Sunshine Escape Enquiry: " & PropertyName

And Tried:
Mail.AddRecipient Response.Write OwnerName, Response.Write OwnerEmail
Mail.Subject    = "Sunshine Escape Enquiry: " & Response.Write PropertyName

And Tried:
Mail.AddRecipient "Response.Write OwnerName", "Response.Write OwnerEmail"
Mail.Subject    = "Sunshine Escape Enquiry: " & "Response.Write PropertyName"

and none of them work!

Please can someone help on this problem!!!!!!
0
net-workx
Asked:
net-workx
  • 2
1 Solution
 
jrramCommented:
Where is your command to send the message?  Should you have a "Mail.Send" or something similar?
0
 
jrramCommented:
More specifically, I think it should be "Mail.SendMail" put after all your other parameters
0
 
gladxmlCommented:
try to change this line

OwnerName = RS("txtFirstName") & " " & RS("txtLastName")

with this...

OwnerName = RS("txtFirstName") & RS("txtLastName")

I am not sure though if this will work since in the code below that is working you only use your first name...

Mail.AddRecipient "Carl", "carl@rico-chet.co.uk"

Maybe it does not accept spaces in between the names... or just use the firstname or lastname and then check the result... like this...

OwnerName = RS("txtFirstName")
OwnerName = RS("txtLastName")

HTH...

HAppy programming...
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now