Question
JMAIL problem
I have adapted some old CDONTS code that I use in order to
send emails via web forms, but for some reason the code below is
kicking up an error.
<%
Dim strBody
Dim strCustBody
Dim strServer
Dim strSMTPServer
strServer = Replace(request.servervariables("SERVER_NAME"),"www.","")
strSMTPServer = "smtp." & strServer
Set objMail = Server.CreateObject("JMail.Message")
objMail.AddRecipient "info@website.com"
objMail.Subject = "Contact via website from " & Request.Form("name")
objMail.From = Request.Form("email")
' Creating the body here
strBody = strBody & vbCrLf & "Date & Time Submitted:" & Date() + Time()
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
strBody = strBody & vbCrLf & "User details:"
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Name: " & Request.Form("name")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Address:"
strBody = strBody & vbCrLf & Request.Form("address")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Telephone: " & Request.Form("tel")
strBody = strBody & vbCrLf & "Mobile: " & Request.Form("mobile")
strBody = strBody & vbCrLf & "Email: " & Request.Form("email")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
strBody = strBody & vbCrLf & "User wrote:"
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "" & Request.Form("query")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
objMail.Body = strBody
if not objMail.Send(strSMTPServer) then
Response.write "<pre>" & msg.log & "</pre>"
end if
Set objMail = Nothing
Set objCustMail = Server.CreateObject("JMail.Message")
objCustMail.AddRecipient Request.Form("email")
objCustMail.Subject = "Thank you for taking the tie to contact us"
objCustMail.from = "info@website.com"
'Creating customer body here
strCustBody = strCustBody & vbCrLf & "Dear: " & Request.Form("name").
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "Thank you for getting in touch."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "You wrote: "
strCustBody = strCustBody & vbCrLf & "" & Request.Form("query").
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "We will respond to you as soon as we can."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "Kindest regards."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "The team"
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "--------------------------------------------"
strCustBody = strCustBody & vbCrLf & "Subscription submitted:" & Date() + Time()
objCustMail.Body = strCustBody
if not objCustMail.Send(strSMTPServer) then
Response.write "<pre>" & msg.log & "</pre>"
end if
Set objCustMail = Nothing
%>
If I remove the second part that goes to the customer, then the send email page works and I receive an email. Why is this happening?
Also, AddRecipient works, but AddRecipientCC and AddRecipientBCC do not work. Again, why is this so?
Thanks
Mat
<%
Dim strBody
Dim strCustBody
Dim strServer
Dim strSMTPServer
strServer = Replace(request.servervariables("SERVER_NAME"),"www.","")
strSMTPServer = "smtp." & strServer
Set objMail = Server.CreateObject("JMail.Message")
objMail.AddRecipient "info@website.com"
objMail.Subject = "Contact via website from " & Request.Form("name")
objMail.From = Request.Form("email")
' Creating the body here
strBody = strBody & vbCrLf & "Date & Time Submitted:" & Date() + Time()
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
strBody = strBody & vbCrLf & "User details:"
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Name: " & Request.Form("name")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Address:"
strBody = strBody & vbCrLf & Request.Form("address")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Telephone: " & Request.Form("tel")
strBody = strBody & vbCrLf & "Mobile: " & Request.Form("mobile")
strBody = strBody & vbCrLf & "Email: " & Request.Form("email")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
strBody = strBody & vbCrLf & "User wrote:"
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "" & Request.Form("query")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
objMail.Body = strBody
if not objMail.Send(strSMTPServer) then
Response.write "<pre>" & msg.log & "</pre>"
end if
Set objMail = Nothing
Set objCustMail = Server.CreateObject("JMail.Message")
objCustMail.AddRecipient Request.Form("email")
objCustMail.Subject = "Thank you for taking the tie to contact us"
objCustMail.from = "info@website.com"
'Creating customer body here
strCustBody = strCustBody & vbCrLf & "Dear: " & Request.Form("name").
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "Thank you for getting in touch."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "You wrote: "
strCustBody = strCustBody & vbCrLf & "" & Request.Form("query").
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "We will respond to you as soon as we can."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "Kindest regards."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "The team"
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "--------------------------------------------"
strCustBody = strCustBody & vbCrLf & "Subscription submitted:" & Date() + Time()
objCustMail.Body = strCustBody
if not objCustMail.Send(strSMTPServer) then
Response.write "<pre>" & msg.log & "</pre>"
end if
Set objCustMail = Nothing
%>
If I remove the second part that goes to the customer, then the send email page works and I receive an email. Why is this happening?
Also, AddRecipient works, but AddRecipientCC and AddRecipientBCC do not work. Again, why is this so?
Thanks
Mat
