I have a form that once submitted needs to send the results to an email address and also send a personalised email responder to the customer who has filled out the form. I have figured out most of the code but am missing the linking code that makes it all work. So far the results are emailed correctly but the auto-responder doesn't send. I've tested each piece seperately and they both work but nor when I put them into the same file. I am very new to ASP and need some help! Thanks.

Here is the relevent code:

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = true
Response.Expires = -1000
Dim JMail, emailmsg, thing, msg
%>


<%
' Amend the Recipient, Subject and redirected page below.
if (Request.Form("Submit")) = "Submit Request" then
emailmsg = ""
emailmsg = emailmsg & "Name=" & request.form("Name") & vbcrlf
emailmsg = emailmsg & "CompanyName=" & request.form("CompanyName") & vbcrlf
emailmsg = emailmsg & "Address1=" & request.form("Address1") & vbcrlf
emailmsg = emailmsg & "Address2=" & request.form("Address2") & vbcrlf
emailmsg = emailmsg & "Postcode=" & request.form("Postcode") & vbcrlf
emailmsg = emailmsg & "DaytimeNumber=" & request.form("DaytimeNumber") & vbcrlf
emailmsg = emailmsg & "EveningNumber=" & request.form("EveningNumber") & vbcrlf
emailmsg = emailmsg & "MobileNumber=" & request.form("MobileNumber") & vbcrlf
emailmsg = emailmsg & request.form("Email") & vbcrlf
emailmsg = emailmsg & "Fax=" & request.form("Fax") & vbcrlf
emailmsg = emailmsg & "DomesticEnquiry=" & request.form("DomesticEnquiry") & vbcrlf
emailmsg = emailmsg & "CommericalEnquiry=" & request.form("CommericalEnquiry") & vbcrlf
emailmsg = emailmsg & "IndustrialEnquiry=" & request.form("IndustrialEnquiry") & vbcrlf
emailmsg = emailmsg & "NewBuildEnquiry=" & request.form("NewBuildEnquiry") & vbcrlf
emailmsg = emailmsg & "MainContractorEnquiry=" & request.form("MainContractorEnquiry") & vbcrlf
emailmsg = emailmsg & "SubContractorEnquiry=" & request.form("SubContractorEnquiry") & vbcrlf
emailmsg = emailmsg & "AdditionalNotes=" & request.form("AdditionalNotes") & vbcrlf
emailmsg = emailmsg & "How_Hear=" & request.form("How_Hear") & vbcrlf

set msg = Server.CreateOBject( "JMail.Message" )
msg.Logging = true
msg.silent = false
msg.From = request.form("email")
msg.AddRecipient [EMAIL="xxx@emailaddress"]xxx@emailaddress[/EMAIL] 'Recipient of emailed form
msg.Subject = "Contact Form" 'Subject of Email
msg.Body = cstr(EmailMsg)
msg.Send( "www15.redstation.co.uk" ) 'Change this to www2, www3 etc
response.redirect "thankyou.htm" 'address of thank you page

emailmsg = ""
emailmsg = emailmsg & request.form("Name") & vbcrlf
emailmsg = emailmsg & request.form("Address1") & vbcrlf
emailmsg = emailmsg & request.form("Address2") & vbcrlf
emailmsg = emailmsg & request.form("Postcode") & vbcrlf & vbcrlf
emailmsg = emailmsg & "Thank you for completing the web application form. We would" & vbcrlf

set msg = Server.CreateOBject( "JMail.Message" )
msg.Logging = true
msg.silent = false
msg.From = [EMAIL="xxx@emailaddress"]xxx[EMAIL="xxx@k"]@[/EMAIL]emailaddress 'Company email address
msg.AddRecipient request.form("email")
msg.Subject = "Thank you for your application" 'Subject of Email
msg.Body = cstr(EmailMsg)
msg.Send( "www15.redstation.co.uk" ) 'Change this to www2, www3 etc
response.redirect "thankyou.htm" 'address of thank you page
end if

%>

Now what you haev to do is, just create an asp page with the name "SendEmail.asp" and save it. Then create an HTML form and in the action property of the form <form action="SendEmail.aso" Method="Post">. And thats it. You are done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.