4dam
11-07-2005, 04:37 PM
Hi,
I have a simple contact form, which adds the contact details to a database and sends an email to me, and should also send a confirmation email to the customer. It works fine, except the second email is not being sent. Would someone be able to tell me what I'm doing wrong? Thanks.
<%
If Request("MM_insert") <> "" Then
theSchema="http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig=server.CreateObject("CDO.Configuration")
cdoConfig.fields.Item(theSchema & "sendusing")=2
cdoConfig.Fields.Item(theSchema & "smtpserver")="my.smtp.server"
cdoConfig.Fields.Update
set cdoMessage=Server.CreateObject("CDO.Message")
cdoMessage.Configuration=cdoConfig
' send email to me
cdoMessage.From= Request.Form("customer_email")
cdoMessage.To= "myemailaddress"
cdoMessage.Subject= "Message subject"
Dim mailbody
mailbody = ""
mailbody = mailbody & "NAME:" & Request("customer_title") & " " & Request("customer_firstname") & " " & Request("customer_lastname") & vbcrlf
mailbody = mailbody & "EMAIL ADDRESS:" & Request("customer_email") & vbcrlf
mailbody = mailbody & "TELEPHONE:" & Request("customer_mobile") & vbcrlf
mailbody = mailbody & "ENQUIRY:" & vbcrlf
mailbody = mailbody & vbcrlf
mailbody = mailbody & Request("customer_comments") & vbcrlf
cdoMessage.TextBody= mailbody
cdoMessage.Send
set cdoMessage=Server.CreateObject("CDO.Message")
cdoMessage.Configuration=cdoConfig
' send confirmation email to customer
cdoMessage.From= "myemailaddress"
cdoMessage.To= Request.Form("customer_email")
cdoMessage.Subject= "Message subject"
mailbody = ""
mailbody = mailbody & "Thank you for your enquiry." & vbcrlf
mailbody = mailbody & "Your enquiry is being processed, and we will be in touch shortly." & vbcrlf
mailbody = mailbody & "If your enquiry is urgent, please call us on XXXXX XXX XXX." & vbcrlf
mailbody = mailbody & vbcrlf
mailbody = mailbody & "NAME:" & Request("customer_title") & " " & Request("customer_firstname") & " " & Request("customer_lastname") & vbcrlf
mailbody = mailbody & "EMAIL ADDRESS:" & Request("customer_email") & vbcrlf
mailbody = mailbody & "TELEPHONE:" & Request("customer_mobile") & vbcrlf
mailbody = mailbody & "ENQUIRY:" & vbcrlf
mailbody = mailbody & vbcrlf
mailbody = mailbody & Request("customer_comments") & vbcrlf
cdoMessage.TextBody= mailbody
cdoMessage.Send
Set cdoMessage=Nothing
Set cdoConfig=Nothing
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
end if
%>
I have a simple contact form, which adds the contact details to a database and sends an email to me, and should also send a confirmation email to the customer. It works fine, except the second email is not being sent. Would someone be able to tell me what I'm doing wrong? Thanks.
<%
If Request("MM_insert") <> "" Then
theSchema="http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig=server.CreateObject("CDO.Configuration")
cdoConfig.fields.Item(theSchema & "sendusing")=2
cdoConfig.Fields.Item(theSchema & "smtpserver")="my.smtp.server"
cdoConfig.Fields.Update
set cdoMessage=Server.CreateObject("CDO.Message")
cdoMessage.Configuration=cdoConfig
' send email to me
cdoMessage.From= Request.Form("customer_email")
cdoMessage.To= "myemailaddress"
cdoMessage.Subject= "Message subject"
Dim mailbody
mailbody = ""
mailbody = mailbody & "NAME:" & Request("customer_title") & " " & Request("customer_firstname") & " " & Request("customer_lastname") & vbcrlf
mailbody = mailbody & "EMAIL ADDRESS:" & Request("customer_email") & vbcrlf
mailbody = mailbody & "TELEPHONE:" & Request("customer_mobile") & vbcrlf
mailbody = mailbody & "ENQUIRY:" & vbcrlf
mailbody = mailbody & vbcrlf
mailbody = mailbody & Request("customer_comments") & vbcrlf
cdoMessage.TextBody= mailbody
cdoMessage.Send
set cdoMessage=Server.CreateObject("CDO.Message")
cdoMessage.Configuration=cdoConfig
' send confirmation email to customer
cdoMessage.From= "myemailaddress"
cdoMessage.To= Request.Form("customer_email")
cdoMessage.Subject= "Message subject"
mailbody = ""
mailbody = mailbody & "Thank you for your enquiry." & vbcrlf
mailbody = mailbody & "Your enquiry is being processed, and we will be in touch shortly." & vbcrlf
mailbody = mailbody & "If your enquiry is urgent, please call us on XXXXX XXX XXX." & vbcrlf
mailbody = mailbody & vbcrlf
mailbody = mailbody & "NAME:" & Request("customer_title") & " " & Request("customer_firstname") & " " & Request("customer_lastname") & vbcrlf
mailbody = mailbody & "EMAIL ADDRESS:" & Request("customer_email") & vbcrlf
mailbody = mailbody & "TELEPHONE:" & Request("customer_mobile") & vbcrlf
mailbody = mailbody & "ENQUIRY:" & vbcrlf
mailbody = mailbody & vbcrlf
mailbody = mailbody & Request("customer_comments") & vbcrlf
cdoMessage.TextBody= mailbody
cdoMessage.Send
Set cdoMessage=Nothing
Set cdoConfig=Nothing
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
end if
%>