Click to See Complete Forum and Search --> : Sending 2 emails from 1 contact form


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

%>

Giskard
11-08-2005, 09:37 AM
try putting the the line

Set cdoMessage=Nothing

after the first cdoMessage.Send as well as where it is now.

4dam
11-10-2005, 05:48 PM
Thanks for that, but it still doesn't work.

Any other suggestions?

/edit

I've answered my own question, there never was a problem with the script. My email account was filtering the second email out as spam - didn't like the "from" address for some reason.

Cheers anyway!