marcum
asked on
Can't send mail with Form
I have recently switched webhosting companies and now have to edit my ASP script pages.
Everything is working except my Send mail. I think I may have to pass authentication (my old server didn't require authentication) but I'm not sure if I have it written correctly.
I'm getting this error on the site..
error '8004020f'
/inquiries.asp, line 139
I added the authentication part to the script and now get this error.
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/inquiries.asp, line 118
I will mark 118 and 139 below.
Here is a piece of the code.
<%
Dim oMessage, objConfig, Flds, eBody
Dim str, temp
Set str = New RegExp
str.Global = True
str.IgnoreCase = True
str.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z- ]{1,}\.){1 ,}[\da-zA- Z-]{2,3}$"
temp = str.Test(Trim(request.form ("eMail")) )
If temp = true Then
Set oMessage = Server.CreateObject("CDO.M essage")
Set objConfig = createobject("CDO.Configur ation")
Set Flds = objConfig.Fields
eBody = "http://schemas.microsoft.com/cdo/configuration/"
With Flds
.Item(eBody & "sendusing") = 2
.Item(eBody & "smtpserver") = "smtp.<CompanyName>.com"
----THIS IS LINE 118---- 'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "< my user account username goes here>"
'Your password on the SMTP server
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "<my password goes here>"
'Server port (typically 25)
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
Set oMessage.Configuration = objConfig
eBody = ""
eBody = eBody & "Subject: " & request.form("Subject") & chr(10)
eBody = eBody & "Company: " & request.form("Company") & chr(10)
eBody = eBody & "First Name: " & request.form("First Name") & chr(10)
eBody = eBody & "Last Name: " & request.form("Last Name") & chr(10)
eBody = eBody & "Job: " & request.form("Job") & chr(10)
eBody = eBody & "Email: " & request.form("eMail") & chr(10)
eBody = eBody & "Phone: " & request.form("Phone") & chr(10)
eBody = eBody & "Fax: " & request.form("Fax") & chr(10)
eBody = eBody & "Address: " & request.form("Address") & chr(10)
eBody = eBody & "City: " & request.form("City") & chr(10)
eBody = eBody & "Zip: " & request.form("Zip") & chr(10)
eBody = eBody & "Inquiry: " & request.form("Inquiry") & chr(10)
With oMessage
.To = "customerservice@<CompanyN ame>.com"
.From = request.form("eMail")
.Subject = "<CompanyName> Inquiry Form"
.Textbody = eBody
---- THIS IS LINE 139 ----- .Send
End With
Set oMessage = Nothing
Response.Write("Thank You, your information has been received.")
Else
%>
Everything is working except my Send mail. I think I may have to pass authentication (my old server didn't require authentication) but I'm not sure if I have it written correctly.
I'm getting this error on the site..
error '8004020f'
/inquiries.asp, line 139
I added the authentication part to the script and now get this error.
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/inquiries.asp, line 118
I will mark 118 and 139 below.
Here is a piece of the code.
<%
Dim oMessage, objConfig, Flds, eBody
Dim str, temp
Set str = New RegExp
str.Global = True
str.IgnoreCase = True
str.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z-
temp = str.Test(Trim(request.form
If temp = true Then
Set oMessage = Server.CreateObject("CDO.M
Set objConfig = createobject("CDO.Configur
Set Flds = objConfig.Fields
eBody = "http://schemas.microsoft.com/cdo/configuration/"
With Flds
.Item(eBody & "sendusing") = 2
.Item(eBody & "smtpserver") = "smtp.<CompanyName>.com"
----THIS IS LINE 118---- 'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "< my user account username goes here>"
'Your password on the SMTP server
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "<my password goes here>"
'Server port (typically 25)
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
Set oMessage.Configuration = objConfig
eBody = ""
eBody = eBody & "Subject: " & request.form("Subject") & chr(10)
eBody = eBody & "Company: " & request.form("Company") & chr(10)
eBody = eBody & "First Name: " & request.form("First Name") & chr(10)
eBody = eBody & "Last Name: " & request.form("Last Name") & chr(10)
eBody = eBody & "Job: " & request.form("Job") & chr(10)
eBody = eBody & "Email: " & request.form("eMail") & chr(10)
eBody = eBody & "Phone: " & request.form("Phone") & chr(10)
eBody = eBody & "Fax: " & request.form("Fax") & chr(10)
eBody = eBody & "Address: " & request.form("Address") & chr(10)
eBody = eBody & "City: " & request.form("City") & chr(10)
eBody = eBody & "Zip: " & request.form("Zip") & chr(10)
eBody = eBody & "Inquiry: " & request.form("Inquiry") & chr(10)
With oMessage
.To = "customerservice@<CompanyN
.From = request.form("eMail")
.Subject = "<CompanyName> Inquiry Form"
.Textbody = eBody
---- THIS IS LINE 139 ----- .Send
End With
Set oMessage = Nothing
Response.Write("Thank You, your information has been received.")
Else
%>
ASKER
I made the change same error.
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/inquiries.asp, line 118
Could it be that I'm using
objMessage.Configuration.F ields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
instead of using
.Item(eBody & "smtpauthenticate") = 1
??
Thanks
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/inquiries.asp, line 118
Could it be that I'm using
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
instead of using
.Item(eBody & "smtpauthenticate") = 1
??
Thanks
here is what I use and it works, maybe you can see your error...
Set objCDOSYS = Server.CreateObject("CDO.M essage")
Set objCDOConf = Server.CreateObject ("CDO.Configuration")
uncomment the next section if remote SMTP
'With objCDOConf
' .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mydomain.com" 'smtp IP or domain
' .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "smtp_username" 'smtp username
' .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "smtp_password" 'smtp password
' .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'Set to 1 if you need to authenticate on the SMTP server
' .Fields.Update
'End With
'Set objCDOSYS.Configuration = objCDOConf
With objCDOSYS
.From = "administrator@site.com"
.To = strEmail & "@site.com"
.Subject = "Subject"
strMessage = "<p>HTML Message</p>"
.HTMLBody = strMessage
.Send
End with
Set objCDOSYS = Nothing
Set objCDOConf = Nothing
Set objCDOSYS = Server.CreateObject("CDO.M
Set objCDOConf = Server.CreateObject ("CDO.Configuration")
uncomment the next section if remote SMTP
'With objCDOConf
' .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mydomain.com" 'smtp IP or domain
' .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "smtp_username" 'smtp username
' .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "smtp_password" 'smtp password
' .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'Set to 1 if you need to authenticate on the SMTP server
' .Fields.Update
'End With
'Set objCDOSYS.Configuration = objCDOConf
With objCDOSYS
.From = "administrator@site.com"
.To = strEmail & "@site.com"
.Subject = "Subject"
strMessage = "<p>HTML Message</p>"
.HTMLBody = strMessage
.Send
End with
Set objCDOSYS = Nothing
Set objCDOConf = Nothing
ASKER
OK So I made few modifications.
The error is now.
CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/inquiries.asp, line 145
here is the code...
<%
Dim oMessage, objConfig, Flds, eBody
Dim str, temp
Set str = New RegExp
str.Global = True
str.IgnoreCase = True
str.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z- ]{1,}\.){1 ,}[\da-zA- Z-]{2,3}$"
temp = str.Test(Trim(request.form ("eMail")) )
If temp = true Then
Set oMessage = Server.CreateObject("CDO.M essage")
Set objConfig = createobject("CDO.Configur ation")
Set Flds = objConfig.Fields
eBody = "http://schemas.microsoft.com/cdo/configuration/"
With Flds
.Item(eBody & "sendusing") = 2
.Item(eBody & "smtpserver") = "smtp.soncebozusa.com"
.Item(eBody & "smtpauthenticate") = 1
.Item(eBody & "sendusername") = "customerservice@soncebozu sa.com"
.Item(eBody & "sendpassword") = "password"
.Item(eBody & "smtpserverport") = 25
.Item(eBody & "smtpusessl") = True
.Item(eBody & "smtpconnectiontimeout") = 10
.Update
End With
Set oMessage.Configuration = objConfig
eBody = ""
eBody = eBody & "Subject: " & request.form("Subject") & chr(10)
eBody = eBody & "Company: " & request.form("Company") & chr(10)
eBody = eBody & "First Name: " & request.form("First Name") & chr(10)
eBody = eBody & "Last Name: " & request.form("Last Name") & chr(10)
eBody = eBody & "Job: " & request.form("Job") & chr(10)
eBody = eBody & "Email: " & request.form("eMail") & chr(10)
eBody = eBody & "Phone: " & request.form("Phone") & chr(10)
eBody = eBody & "Fax: " & request.form("Fax") & chr(10)
eBody = eBody & "Address: " & request.form("Address") & chr(10)
eBody = eBody & "City: " & request.form("City") & chr(10)
eBody = eBody & "Zip: " & request.form("Zip") & chr(10)
eBody = eBody & "Inquiry: " & request.form("Inquiry") & chr(10)
With oMessage
.To = "customerservice@soncebozu sa.com"
.From = request.form("eMail")
.Subject = "SoncebozUSA Inquiry Form"
.Textbody = eBody
-----THIS IS LINE 145 ----- .Send
End With
Set oMessage = Nothing
Response.Write("Thank You, your information has been received.")
Else
%>
The error is now.
CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/inquiries.asp, line 145
here is the code...
<%
Dim oMessage, objConfig, Flds, eBody
Dim str, temp
Set str = New RegExp
str.Global = True
str.IgnoreCase = True
str.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z-
temp = str.Test(Trim(request.form
If temp = true Then
Set oMessage = Server.CreateObject("CDO.M
Set objConfig = createobject("CDO.Configur
Set Flds = objConfig.Fields
eBody = "http://schemas.microsoft.com/cdo/configuration/"
With Flds
.Item(eBody & "sendusing") = 2
.Item(eBody & "smtpserver") = "smtp.soncebozusa.com"
.Item(eBody & "smtpauthenticate") = 1
.Item(eBody & "sendusername") = "customerservice@soncebozu
.Item(eBody & "sendpassword") = "password"
.Item(eBody & "smtpserverport") = 25
.Item(eBody & "smtpusessl") = True
.Item(eBody & "smtpconnectiontimeout") = 10
.Update
End With
Set oMessage.Configuration = objConfig
eBody = ""
eBody = eBody & "Subject: " & request.form("Subject") & chr(10)
eBody = eBody & "Company: " & request.form("Company") & chr(10)
eBody = eBody & "First Name: " & request.form("First Name") & chr(10)
eBody = eBody & "Last Name: " & request.form("Last Name") & chr(10)
eBody = eBody & "Job: " & request.form("Job") & chr(10)
eBody = eBody & "Email: " & request.form("eMail") & chr(10)
eBody = eBody & "Phone: " & request.form("Phone") & chr(10)
eBody = eBody & "Fax: " & request.form("Fax") & chr(10)
eBody = eBody & "Address: " & request.form("Address") & chr(10)
eBody = eBody & "City: " & request.form("City") & chr(10)
eBody = eBody & "Zip: " & request.form("Zip") & chr(10)
eBody = eBody & "Inquiry: " & request.form("Inquiry") & chr(10)
With oMessage
.To = "customerservice@soncebozu
.From = request.form("eMail")
.Subject = "SoncebozUSA Inquiry Form"
.Textbody = eBody
-----THIS IS LINE 145 ----- .Send
End With
Set oMessage = Nothing
Response.Write("Thank You, your information has been received.")
Else
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help, after working out the little bugs it turns out the Hosting company was blocking the smtp and provided me with a secureSmtp server instead. It would have been nice to have the hosting company tell me earlier but better late then never I suppose.
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
should be
objMessage.Configuration.F
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1