PDA

View Full Version : Resolved Form data from my contact form missing from email


norzar2
10-23-2008, 09:13 PM
Thanks for helping I really appreciate it.

I switched servers and now my contact form doesn't work.
My new host gave me some code and now I have the script sending mail again
But the form data is gone
Could someone point out what is missing?

My original submit.asp that worked on last server.



<%
Dim strBody, strSubject, objMail, aRecipients

set objMail = Server.CreateObject("CDO.Message")
strSubject = "Widget - Jones Interactive"
aRecipients = "thebass@widgetjonesinteractive.com"
strBody = ""

for i = 1 to Request.Form.Count - 1
strBody = strBody & "<font color=#FF0000><b>" & Request.Form.Key(i) & ":</b></font> " & Request.Form.Item(i) & "<br />"
next

objMail.To = aRecipients
objMail.From = "contact@website.com"
objMail.Subject = strSubject
objMail.HTMLBody = "<br /><h3>New Message from Website!</h3><br />" & strBody
objMail.Send
Response.Write "<br><p align=center class=style5><b><h1>Thank you for your Message!</h1><br><br><h2>We will be in touch soon!</h2></b><br><BR><BR></p>"
set objMail = Nothing
%>




updated submit.asp that sends mail but doesn't collect my form data



<%
on error resume next
Set oMail = Server.CreateObject("CDO.Message")
'Set oConf = Server.CreateObject("CDO.Configuration")
'Set oFields = oConf.Fields

oMail.From = "thebass@widgetjonesinteractive.com"

oMail.To = "thebass@widgetjonesinteractive.com"
'oMail.cc = "some@otherdomain.com"

oMail.Subject = "Just a CDO test"

oMail.textBody = "Text Body of the message"

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.widgetjonesinteractive.com"

'Server port (typically 25)

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "thebass@widgetjonesinteractive.com"
oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "EasyMoneyF3"

oMail.Configuration.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = 1
' The following fields are only used if the previous authentication value is set to 1 or 2
oMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname").Value = "thebass@widgetjonesinteractive.com"

oMail.Configuration.Fields.Update

'==End remote SMTP server configuration section==

oMail.Send()
'Clean up server resources.
Set oMail = nothing

If err.number = 0 then
response.write("Mail Send Success")
else
response.write(err.number & " - " & err.description)
end if


%>

norzar2
10-23-2008, 10:07 PM
I've been reading and I see now that my updated submit.asp
would need this code


for i = 1 to Request.Form.Count - 1
strBody = strBody & "<font color=#FF0000><b>" & Request.Form.Key(i) & ":</b></font> " & Request.Form.Item(i) & "<br />"
next


But I don't know where in the script to insert it, and do I need these elements?

Dim strBody
strBody = ""

hinch
10-24-2008, 02:04 AM
this should work their code is a messier version of your existing code thats all but they've explicitly defined a load of vars and settings with your old code assumes are already in place. not really required but I guess its just being thorough.

I guess the only real difference is that your new host SMTP server requires a password to send as its not being sent through SMTP on the actual hosting machine but instead from a dedicated mail server you could just have easily edited your existing script with their changes but anyway

<%
on error resume next
Set oMail = Server.CreateObject("CDO.Message")
'Set oConf = Server.CreateObject("CDO.Configuration")
'Set oFields = oConf.Fields

oMail.From = "thebass@widgetjonesinteractive.com"

oMail.To = "thebass@widgetjonesinteractive.com"
'oMail.cc = "some@otherdomain.com"

oMail.Subject = "Just a CDO test"

for i = 1 to Request.Form.Count - 1
strBody = strBody & "<font color=#FF0000><b>" & Request.Form.Key(i) & ":</b></font> " & Request.Form.Item(i) & "<br />"
next
oMail.HTMLBody = "<br /><h3>New Message from Website!</h3><br />" & strBody


'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.widgetjonesinteractive.com"

'Server port (typically 25)

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "thebass@widgetjonesinteractive.com"
oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "EasyMoneyF3"

oMail.Configuration.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = 1
' The following fields are only used if the previous authentication value is set to 1 or 2
oMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname").Value = "thebass@widgetjonesinteractive.com"

oMail.Configuration.Fields.Update

'==End remote SMTP server configuration section==

oMail.Send()
'Clean up server resources.
Set oMail = nothing

If err.number = 0 then
response.write("Mail Send Success")
else
response.write(err.number & " - " & err.description)
end if


%>

norzar2
10-24-2008, 06:32 AM
Thanks a million Hinch :)
And thank you too for explaining some of the script to me.