Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Automatic Email response with ASP/CDONTS

    Hi,

    I am using an html contact form via asp script on my website which sends the information to my email address and then redirects customers to a Thank You page. What I would like to add is an automatic email reply to customers filling out the form that sends them the form information as well as a scripted message with a body message.

    How can I do this? I have try using mail.Bcc, but it will just send them the same form information, I get, however I would like to also include the below message as well.


    Your request for an appointment has been submitted with the following information:

    …..(the input body information that I receive goes here)….

    If your request is more than two working days from the date of your submittal, we will send you a confirmation of your appointment by email.

    Thank you for using our website. We look forward to seeing you soon.

    Sincerely,
    Your Service Team
    Company Name | www.mycompany.com
    000-000-0000 | service@mycompany.com




    Here is my code:

    Code:
    <%
    
    
    ' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    Dim Name
    Dim Street
    Dim PreferredAppointmentDate
    Dim Mobilephone
    Dim Workphone
    Dim Housephone
    Dim LicensePlateNumber
    Dim Parishandpostalcode
    Dim Comment
    Dim Infochange
    Dim Namechange
    
    
    ' get posted data into variables
    EmailFrom = Trim(Request.Form("EmailFrom")) 
    EmailTo = "me@mycompany.com"
    Subject = "Request for Service Appointment"
    Name = Trim(Request.Form("Name")) 
    Namechange = Trim(Request.Form("Namechange")) 
    Street = Trim(Request.Form("Street"))
    PreferredAppointmentDate = Trim(Request.Form("PreferredAppointmentDate"))
    LicensePlateNumber = Trim(Request.Form("LicensePlateNumber"))
    Parishandpostalcode = Trim(Request.Form("Parishandpostalcode"))
    Comment = Trim(Request.Form("Comment"))
    Mobilephone = Trim(Request.Form("Mobilephone"))
    Workphone = Trim(Request.Form("Workphone"))
    Housephone = Trim(Request.Form("Housephone"))
    Infochange = Trim(Request.Form("Infochange"))
    
    
    ' validation
    Dim validationOK
    validationOK=true
    If (Trim(EmailFrom)="") Then validationOK=false
    If (Trim(Name)="") Then validationOK=false
    If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)
    
    ' prepare email body text
    Dim Body
    Body = Body & "Preferred Appointment Date: " & PreferredAppointmentDate & VbCrLf
    Body = Body & "License Plate Number: " & LicensePlateNumber & VbCrLf
    Body = Body & "Full Name: " & Name & VbCrLf
    Body = Body & "Service Required: " & Comment & VbCrLf
    Body = Body & "Update Contact Info: " & Infochange & VbCrLf
    Body = Body & "Full Name: " & Namechange & VbCrLf
    Body = Body & "Street: " & Street & VbCrLf
    Body = Body & "Parish/Postal Code: " & Parishandpostalcode & VbCrLf
    Body = Body & "Mobile Phone: " & Mobilephone & VbCrLf
    Body = Body & "Work Phone: " & Workphone & VbCrLf
    Body = Body & "House Phone: " & Housephone & VbCrLf
    
    
    ' send email 
    Dim mail
    Set mail = Server.CreateObject("CDONTS.NewMail") 
    mail.To = EmailTo
    mail.From = EmailFrom
    mail.Subject = Subject
    mail.Body = Body
    mail.Send 
    
    
    ' redirect to success page 
    Response.Redirect("contacty.asp?" )
    %>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,658 Times in 4,620 Posts
    You could send two separate emails.

    But unless it bothers you a lot, why not simply put that "boiler plate" language into the original email and send it to yourself and the customer? You'll see the extra "boiler plate" stuff, but so what? It won't interfere with the details of the request, which is the important part.

  • #3
    New Coder
    Join Date
    Jul 2011
    Location
    Spain [near Alicante]
    Posts
    10
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Ditto what Old Pedant has said, but there is another option almost as easy as that! You run last part of the routine twice [You've already declared the data for the rest]:

    Code:
    <%
    ' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    Dim Name
    Dim Street
    Dim PreferredAppointmentDate
    Dim Mobilephone
    Dim Workphone
    Dim Housephone
    Dim LicensePlateNumber
    Dim Parishandpostalcode
    Dim Comment
    Dim Infochange
    Dim Namechange
    
    
    ' get posted data into variables
    EmailFrom = Trim(Request.Form("EmailFrom")) 
    EmailTo = "me@mycompany.com"
    Subject = "Request for Service Appointment"
    Name = Trim(Request.Form("Name")) 
    Namechange = Trim(Request.Form("Namechange")) 
    Street = Trim(Request.Form("Street"))
    PreferredAppointmentDate = Trim(Request.Form("PreferredAppointmentDate"))
    LicensePlateNumber = Trim(Request.Form("LicensePlateNumber"))
    Parishandpostalcode = Trim(Request.Form("Parishandpostalcode"))
    Comment = Trim(Request.Form("Comment"))
    Mobilephone = Trim(Request.Form("Mobilephone"))
    Workphone = Trim(Request.Form("Workphone"))
    Housephone = Trim(Request.Form("Housephone"))
    Infochange = Trim(Request.Form("Infochange"))
    
    
    ' validation
    Dim validationOK
    validationOK=true
    If (Trim(EmailFrom)="") Then validationOK=false
    If (Trim(Name)="") Then validationOK=false
    If (validationOK=false) Then Response.Redirect("error.htm?" &amp; EmailFrom)
    
    ' prepare email body text for the eMail to your company  *****
    Dim Body
    Body = Body &amp; "Preferred Appointment Date: " &amp; PreferredAppointmentDate &amp; VbCrLf
    Body = Body &amp; "License Plate Number: " &amp; LicensePlateNumber &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Name &amp; VbCrLf
    Body = Body &amp; "Service Required: " &amp; Comment &amp; VbCrLf
    Body = Body &amp; "Update Contact Info: " &amp; Infochange &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Namechange &amp; VbCrLf
    Body = Body &amp; "Street: " &amp; Street &amp; VbCrLf
    Body = Body &amp; "Parish/Postal Code: " &amp; Parishandpostalcode &amp; VbCrLf
    Body = Body &amp; "Mobile Phone: " &amp; Mobilephone &amp; VbCrLf
    Body = Body &amp; "Work Phone: " &amp; Workphone &amp; VbCrLf
    Body = Body &amp; "House Phone: " &amp; Housephone &amp; VbCrLf
    
    
    ' send email 
    Dim mail
    Set mail = Server.CreateObject("CDONTS.NewMail") 
    mail.To = EmailTo
    mail.From = EmailFrom
    mail.Subject = Subject
    mail.Body = Body
    mail.Send 
    
    
    ' prepare email body text for the eMail to the client  *****
    Dim Body
    Body = Body &amp; "Your request for an appointment has been submitted with the following information:" & &amp; VbCrLfBody = Body &amp; "Preferred Appointment Date: " &amp; PreferredAppointmentDate &amp; VbCrLf
    Body = Body &amp; "License Plate Number: " &amp; LicensePlateNumber &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Name &amp; VbCrLf
    Body = Body &amp; "Service Required: " &amp; Comment &amp; VbCrLf
    Body = Body &amp; "Update Contact Info: " &amp; Infochange &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Namechange &amp; VbCrLf
    Body = Body &amp; "Street: " &amp; Street &amp; VbCrLf
    Body = Body &amp; "Parish/Postal Code: " &amp; Parishandpostalcode &amp; VbCrLf
    Body = Body &amp; "Mobile Phone: " &amp; Mobilephone &amp; VbCrLf
    Body = Body &amp; "Work Phone: " &amp; Workphone &amp; VbCrLf
    Body = Body &amp; "House Phone: " &amp; Housephone &amp; VbCrLf &amp; VbCrLf
    Body = Body &amp; "If your request is more than two working days from the date of your submittal, we will send you a confirmation of your appointment by email." &amp; VbCrLf &amp; VbCrLf
    Body = Body &amp; "Thank you for using our website. We look forward to seeing you soon" &amp; VbCrLf &amp; VbCrLf
    Body = Body &amp; "Sincerely," &amp; VbCrLf
    Body = Body &amp; "Your Service Team" &amp; VbCrLf
    Body = Body &amp; "Company Name | www.mycompany.com" &amp; VbCrLf
    Body = Body &amp; "000-000-0000 | service@mycompany.com" &amp; VbCrLf
    
    
    ' send email - see TO/FROM are swapped around  *****
    Dim mail
    Set mail = Server.CreateObject("CDONTS.NewMail") 
    mail.To = EmailFrom
    mail.From = EmailTo
    mail.Subject = Subject
    mail.Body = Body
    mail.Send 
    
    ' redirect to success page 
    Response.Redirect("contacty.asp?" )
    %>

  • Users who have thanked NomadicT for this post:

    Gtdonna (08-17-2011)

  • #4
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks very much for the insight, much appreciated.

    I had actually soon afterwards put in a

    mail.Bcc = EmailFrom which had worked

    Tested NomadicT solution and that worked too. Thanks

  • #5
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by NomadicT View Post
    Ditto what Old Pedant has said, but there is another option almost as easy as that! You run last part of the routine twice [You've already declared the data for the rest]:

    Code:
    <%
    ' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    Dim Name
    Dim Street
    Dim PreferredAppointmentDate
    Dim Mobilephone
    Dim Workphone
    Dim Housephone
    Dim LicensePlateNumber
    Dim Parishandpostalcode
    Dim Comment
    Dim Infochange
    Dim Namechange
    
    
    ' get posted data into variables
    EmailFrom = Trim(Request.Form("EmailFrom")) 
    EmailTo = "me@mycompany.com"
    Subject = "Request for Service Appointment"
    Name = Trim(Request.Form("Name")) 
    Namechange = Trim(Request.Form("Namechange")) 
    Street = Trim(Request.Form("Street"))
    PreferredAppointmentDate = Trim(Request.Form("PreferredAppointmentDate"))
    LicensePlateNumber = Trim(Request.Form("LicensePlateNumber"))
    Parishandpostalcode = Trim(Request.Form("Parishandpostalcode"))
    Comment = Trim(Request.Form("Comment"))
    Mobilephone = Trim(Request.Form("Mobilephone"))
    Workphone = Trim(Request.Form("Workphone"))
    Housephone = Trim(Request.Form("Housephone"))
    Infochange = Trim(Request.Form("Infochange"))
    
    
    ' validation
    Dim validationOK
    validationOK=true
    If (Trim(EmailFrom)="") Then validationOK=false
    If (Trim(Name)="") Then validationOK=false
    If (validationOK=false) Then Response.Redirect("error.htm?" &amp; EmailFrom)
    
    ' prepare email body text for the eMail to your company  *****
    Dim Body
    Body = Body &amp; "Preferred Appointment Date: " &amp; PreferredAppointmentDate &amp; VbCrLf
    Body = Body &amp; "License Plate Number: " &amp; LicensePlateNumber &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Name &amp; VbCrLf
    Body = Body &amp; "Service Required: " &amp; Comment &amp; VbCrLf
    Body = Body &amp; "Update Contact Info: " &amp; Infochange &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Namechange &amp; VbCrLf
    Body = Body &amp; "Street: " &amp; Street &amp; VbCrLf
    Body = Body &amp; "Parish/Postal Code: " &amp; Parishandpostalcode &amp; VbCrLf
    Body = Body &amp; "Mobile Phone: " &amp; Mobilephone &amp; VbCrLf
    Body = Body &amp; "Work Phone: " &amp; Workphone &amp; VbCrLf
    Body = Body &amp; "House Phone: " &amp; Housephone &amp; VbCrLf
    
    
    ' send email 
    Dim mail
    Set mail = Server.CreateObject("CDONTS.NewMail") 
    mail.To = EmailTo
    mail.From = EmailFrom
    mail.Subject = Subject
    mail.Body = Body
    mail.Send 
    
    
    ' prepare email body text for the eMail to the client  *****
    Dim Body
    Body = Body &amp; "Your request for an appointment has been submitted with the following information:" & &amp; VbCrLfBody = Body &amp; "Preferred Appointment Date: " &amp; PreferredAppointmentDate &amp; VbCrLf
    Body = Body &amp; "License Plate Number: " &amp; LicensePlateNumber &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Name &amp; VbCrLf
    Body = Body &amp; "Service Required: " &amp; Comment &amp; VbCrLf
    Body = Body &amp; "Update Contact Info: " &amp; Infochange &amp; VbCrLf
    Body = Body &amp; "Full Name: " &amp; Namechange &amp; VbCrLf
    Body = Body &amp; "Street: " &amp; Street &amp; VbCrLf
    Body = Body &amp; "Parish/Postal Code: " &amp; Parishandpostalcode &amp; VbCrLf
    Body = Body &amp; "Mobile Phone: " &amp; Mobilephone &amp; VbCrLf
    Body = Body &amp; "Work Phone: " &amp; Workphone &amp; VbCrLf
    Body = Body &amp; "House Phone: " &amp; Housephone &amp; VbCrLf &amp; VbCrLf
    Body = Body &amp; "If your request is more than two working days from the date of your submittal, we will send you a confirmation of your appointment by email." &amp; VbCrLf &amp; VbCrLf
    Body = Body &amp; "Thank you for using our website. We look forward to seeing you soon" &amp; VbCrLf &amp; VbCrLf
    Body = Body &amp; "Sincerely," &amp; VbCrLf
    Body = Body &amp; "Your Service Team" &amp; VbCrLf
    Body = Body &amp; "Company Name | www.mycompany.com" &amp; VbCrLf
    Body = Body &amp; "000-000-0000 | service@mycompany.com" &amp; VbCrLf
    
    
    ' send email - see TO/FROM are swapped around  *****
    Dim mail
    Set mail = Server.CreateObject("CDONTS.NewMail") 
    mail.To = EmailFrom
    mail.From = EmailTo
    mail.Subject = Subject
    mail.Body = Body
    mail.Send 
    
    ' redirect to success page 
    Response.Redirect("contacty.asp?" )
    %>
    This code will throw an error. Why? because in two instances you have declared the same variable twice. (Dim Body and also Dim Mail)

    Next, CDONTS was depricated with windows 2000 and not shipped or available after that, so it should always be CDO.Message that is used

    and lastly you do not need to open an object more than once. the very first time you open the mail object it then becomes available throught the page. you can send as many messages as you like with the single object.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •