apresto
asked on
RED ALERT! CDO Error - Error with "SendUsing"
Hey guys, im having a nightmare over here, im not too good with CDO as is but this is taking the pis*!
Basically i tried this on the intranet at work and it sends mails fine, when i send it to the user they get this error:
CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
Its pointing to the
MyMail.send Line
Any ideas
<%
'********Dimension Variables************
'Optional Field
Dim Comments
'Mandatory fields
Dim Purpose, Firstname, Lastname, Profession, Industry, jobtitle, Address, City, State, Zipcode, phone, email, pref_contact
'********Request Form values************
Purpose = request.form("purpose")
firstname = trim(request.form("Firstna me"))
lastname = trim(request.form("lastnam e"))
profession = trim(request.form("profess ion"))
industry = trim(request.form("industr y"))
jobtitle = trim(request.form("jobtitl e"))
address = trim(request.form("address "))
city = trim(request.form("city"))
state = trim(request.form("state") )
zipcode = trim(request.form("zipcode "))
phone = trim(request.form("phone") )
email = trim(request.form("email") )
pref_contact = trim(request.form("pref_co ntact"))
Comments = request.form("comments")
'********Create Email************
Dim sfrom, sto, scc, sbcc, sSubject, Sbody
sfrom = email
sto = Purpose
scc = ""
sbcc = ""
sSubject = "Feedback From Internet"
'Create Email Message Body - HTML formated
Sbody = "<TABLE border=""0"" cellpadding=""4"" cellspacing=""0"">"
Sbody = sbody & "<TR><td colspan=""2"">A Contact Form has been completed by <b>" & Firstname & " " & Lastname
Sbody = Sbody & "</b>, who wishes to be contacted by <b>" & pref_contact & "</b><br><br></td></tr>"
Sbody = Sbody & "<tr><td colspan=""2"">Other Information Supplied is as follows:-<br><br></td></tr >"
Sbody = Sbody & "<tr><td><strong>Professio n :</strong></td><td>" & Profession & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Industry :</strong></td><td>" & industry & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Job title :</strong></td><td>" & jobtitle & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Address :</strong></td><td>" & address & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>City :</strong></td><td>"& City & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>State :</strong></td><td>" & State & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>ZipCode :</strong></td><td>" & Zipcode & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Phone :</strong></td><td>" & Phone & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Email :</strong></td><td>" & email & "</td></tr></table>"
'If comments have been left show them in the mail, if not exclude comments altogether
If len(trim(comments))>0 Then
sbody = sbody & "<br><table><tr><td><stron g>Comments </strong> : " & "<br>" & comments & "</td></tr></table>"
End If
'********Send Email************
Call Sendmail(Sfrom, Sto, Scc, Sbcc, Ssubject, sbody)
function Sendmail(Sfrom, Sto, Scc, Sbcc, Ssubject, sbody)
Dim MyMail
Set MyMail = server.createobject("CDO.m essage")
MyMail.From = sfrom
MyMail.To = sTo
MyMail.Cc = sCc
myMail.bcc = Sbcc
MyMail.Subject = Ssubject
MyMail.htmlbody = sbody
MyMail.send
Set MyMail = nothing
End Function
'********Redirect to Confirmation Page************
Response.redirect "email_confirmation.htm"
%>
Thanks in advance. I dont know what the smtp is or anything else so you will have to bear wioth me, and try not to assume i know things because i prob wont :o)
Basically i tried this on the intranet at work and it sends mails fine, when i send it to the user they get this error:
CDO.Message.1 error '80040220'
The "SendUsing" configuration value is invalid.
Its pointing to the
MyMail.send Line
Any ideas
<%
'********Dimension Variables************
'Optional Field
Dim Comments
'Mandatory fields
Dim Purpose, Firstname, Lastname, Profession, Industry, jobtitle, Address, City, State, Zipcode, phone, email, pref_contact
'********Request Form values************
Purpose = request.form("purpose")
firstname = trim(request.form("Firstna
lastname = trim(request.form("lastnam
profession = trim(request.form("profess
industry = trim(request.form("industr
jobtitle = trim(request.form("jobtitl
address = trim(request.form("address
city = trim(request.form("city"))
state = trim(request.form("state")
zipcode = trim(request.form("zipcode
phone = trim(request.form("phone")
email = trim(request.form("email")
pref_contact = trim(request.form("pref_co
Comments = request.form("comments")
'********Create Email************
Dim sfrom, sto, scc, sbcc, sSubject, Sbody
sfrom = email
sto = Purpose
scc = ""
sbcc = ""
sSubject = "Feedback From Internet"
'Create Email Message Body - HTML formated
Sbody = "<TABLE border=""0"" cellpadding=""4"" cellspacing=""0"">"
Sbody = sbody & "<TR><td colspan=""2"">A Contact Form has been completed by <b>" & Firstname & " " & Lastname
Sbody = Sbody & "</b>, who wishes to be contacted by <b>" & pref_contact & "</b><br><br></td></tr>"
Sbody = Sbody & "<tr><td colspan=""2"">Other Information Supplied is as follows:-<br><br></td></tr
Sbody = Sbody & "<tr><td><strong>Professio
Sbody = Sbody & "<tr><td><strong>Industry :</strong></td><td>" & industry & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Job title :</strong></td><td>" & jobtitle & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Address :</strong></td><td>" & address & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>City :</strong></td><td>"& City & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>State :</strong></td><td>" & State & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>ZipCode :</strong></td><td>" & Zipcode & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Phone :</strong></td><td>" & Phone & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Email :</strong></td><td>" & email & "</td></tr></table>"
'If comments have been left show them in the mail, if not exclude comments altogether
If len(trim(comments))>0 Then
sbody = sbody & "<br><table><tr><td><stron
End If
'********Send Email************
Call Sendmail(Sfrom, Sto, Scc, Sbcc, Ssubject, sbody)
function Sendmail(Sfrom, Sto, Scc, Sbcc, Ssubject, sbody)
Dim MyMail
Set MyMail = server.createobject("CDO.m
MyMail.From = sfrom
MyMail.To = sTo
MyMail.Cc = sCc
myMail.bcc = Sbcc
MyMail.Subject = Ssubject
MyMail.htmlbody = sbody
MyMail.send
Set MyMail = nothing
End Function
'********Redirect to Confirmation Page************
Response.redirect "email_confirmation.htm"
%>
Thanks in advance. I dont know what the smtp is or anything else so you will have to bear wioth me, and try not to assume i know things because i prob wont :o)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have tested it before, and it works fine. I don't know this for certain, but I think that this has something to do with your using a local vs. remote smtp server.
I recommend creating a separate test page with the code that I gave you to verify that it works in the environment that you need it to rather than trying to integrate it into your own code straight away.
FtB
I recommend creating a separate test page with the code that I gave you to verify that it works in the environment that you need it to rather than trying to integrate it into your own code straight away.
FtB
ASKER
Thanks ftb, Thats what i did it put it in a page by itself and tried it that way. Im using it on a host not on my IIS, the host is ipower or something, its american and im in uk so its hard to contact them. But the people i am doing this for said it supports CDOSYS.
Does this line need to have the single quote removed?:
'CALL SendMailCDOSYS("a@b.com"," c@d.com"," test",strM ailBody,Tr ue,"mail.y ahoo.com")
Does this line need to have the single quote removed?:
'CALL SendMailCDOSYS("a@b.com","
That line is to show you how to call the subroutine. Uncomment it and put in the real values.
FtB
FtB
ASKER
i tried it, can you see anything wrong with this:
<html><head><title></title ></head>
<body>Your email has been sent.<%
'********Dimension Variables************
'Optional Field
Dim Comments
'Mandatory fields
Dim Purpose, Firstname, Lastname, Profession, Industry, jobtitle, Address, City, State, Zipcode, phone, email, pref_contact
'********Request Form values************
Purpose = request.form("purpose")
firstname = trim(request.form("Firstna me"))
lastname = trim(request.form("lastnam e"))
profession = trim(request.form("profess ion"))
industry = trim(request.form("industr y"))
jobtitle = trim(request.form("jobtitl e"))
address = trim(request.form("address "))
city = trim(request.form("city"))
state = trim(request.form("state") )
zipcode = trim(request.form("zipcode "))
phone = trim(request.form("phone") )
email = trim(request.form("email") )
pref_contact = trim(request.form("pref_co ntact"))
Comments = request.form("comments")
'********Create Email************
Dim sfrom, sto, scc, sbcc, sSubject, Sbody
sfrom = email
sto = "apresto84@ntlworld.com"
scc = ""
sbcc = ""
sSubject = "Feedback From Internet"
'Create Email Message Body - HTML formated
Sbody = "<TABLE border=""0"" cellpadding=""4"" cellspacing=""0"">"
Sbody = sbody & "<TR><td colspan=""2"">A Contact Form has been completed by <b>" & Firstname & " " & Lastname
Sbody = Sbody & "</b>, who wishes to be contacted by <b>" & pref_contact & "</b><br><br></td></tr>"
Sbody = Sbody & "<tr><td colspan=""2"">Other Information Supplied is as follows:-<br><br></td></tr >"
Sbody = Sbody & "<tr><td><strong>Professio n :</strong></td><td>" & Profession & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Industry :</strong></td><td>" & industry & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Job title :</strong></td><td>" & jobtitle & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Address :</strong></td><td>" & address & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>City :</strong></td><td>"& City & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>State :</strong></td><td>" & State & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>ZipCode :</strong></td><td>" & Zipcode & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Phone :</strong></td><td>" & Phone & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Email :</strong></td><td>" & email & "</td></tr></table>"
'If comments have been left show them in the mail, if not exclude comments altogether
If len(trim(comments))>0 Then
sbody = sbody & "<br><table><tr><td><stron g>Comments </strong> : " & "<br>" & comments & "</td></tr></table>"
End If
'** SUBROUTINE TO SEND EMAIL USING CDOSYS **
'**USAGE **
Call SendMailCDOSYS(sFrom,sTO,s Subject,sB ody,"mail. trlx.org")
Sub SendMailCDOSYS(sFrom,sTO,s Subject,sB ody,sMailS erver)
On Error Resume Next
Dim objCDOConf,objCDOSYS
Set objCDOSYS = Server.CreateObject("CDO.M essage")
Set objCDOConf = Server.CreateObject ("CDO.Configuration")
With objCDOConf
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With
Set objCDOSYS.Configuration = objCDOConf
With objCDOSYS
.From = sFrom
.To = sTo
.Subject = sSubject
.HTMLbody = sBody
' ** SEND THE E-MAIL **
.Send
End with
' ** CLOSE THE SERVER MAIL OBJECT **
Set objCDOSYS = Nothing
End Sub
%>
</body>
</html>
<html><head><title></title
<body>Your email has been sent.<%
'********Dimension Variables************
'Optional Field
Dim Comments
'Mandatory fields
Dim Purpose, Firstname, Lastname, Profession, Industry, jobtitle, Address, City, State, Zipcode, phone, email, pref_contact
'********Request Form values************
Purpose = request.form("purpose")
firstname = trim(request.form("Firstna
lastname = trim(request.form("lastnam
profession = trim(request.form("profess
industry = trim(request.form("industr
jobtitle = trim(request.form("jobtitl
address = trim(request.form("address
city = trim(request.form("city"))
state = trim(request.form("state")
zipcode = trim(request.form("zipcode
phone = trim(request.form("phone")
email = trim(request.form("email")
pref_contact = trim(request.form("pref_co
Comments = request.form("comments")
'********Create Email************
Dim sfrom, sto, scc, sbcc, sSubject, Sbody
sfrom = email
sto = "apresto84@ntlworld.com"
scc = ""
sbcc = ""
sSubject = "Feedback From Internet"
'Create Email Message Body - HTML formated
Sbody = "<TABLE border=""0"" cellpadding=""4"" cellspacing=""0"">"
Sbody = sbody & "<TR><td colspan=""2"">A Contact Form has been completed by <b>" & Firstname & " " & Lastname
Sbody = Sbody & "</b>, who wishes to be contacted by <b>" & pref_contact & "</b><br><br></td></tr>"
Sbody = Sbody & "<tr><td colspan=""2"">Other Information Supplied is as follows:-<br><br></td></tr
Sbody = Sbody & "<tr><td><strong>Professio
Sbody = Sbody & "<tr><td><strong>Industry :</strong></td><td>" & industry & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Job title :</strong></td><td>" & jobtitle & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Address :</strong></td><td>" & address & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>City :</strong></td><td>"& City & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>State :</strong></td><td>" & State & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>ZipCode :</strong></td><td>" & Zipcode & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Phone :</strong></td><td>" & Phone & "</td></tr>"
Sbody = Sbody & "<tr><td><strong>Email :</strong></td><td>" & email & "</td></tr></table>"
'If comments have been left show them in the mail, if not exclude comments altogether
If len(trim(comments))>0 Then
sbody = sbody & "<br><table><tr><td><stron
End If
'** SUBROUTINE TO SEND EMAIL USING CDOSYS **
'**USAGE **
Call SendMailCDOSYS(sFrom,sTO,s
Sub SendMailCDOSYS(sFrom,sTO,s
On Error Resume Next
Dim objCDOConf,objCDOSYS
Set objCDOSYS = Server.CreateObject("CDO.M
Set objCDOConf = Server.CreateObject ("CDO.Configuration")
With objCDOConf
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With
Set objCDOSYS.Configuration = objCDOConf
With objCDOSYS
.From = sFrom
.To = sTo
.Subject = sSubject
.HTMLbody = sBody
' ** SEND THE E-MAIL **
.Send
End with
' ** CLOSE THE SERVER MAIL OBJECT **
Set objCDOSYS = Nothing
End Sub
%>
</body>
</html>
That looks correct. What happens when you try it?
FtB
FtB
ASKER
It just says
Your email has been sent
the page is lying to me!!!!!
Im in a chat with the hosting company now im gonna see if they can tell me what the hell is going on, ill post back in abit with feedback, thanks for your help fritz, always appreciated
Your email has been sent
the page is lying to me!!!!!
Im in a chat with the hosting company now im gonna see if they can tell me what the hell is going on, ill post back in abit with feedback, thanks for your help fritz, always appreciated
I can't help but wonder if there is a series of mails in the Bad Mail folder that haven't made it out. Or, there may be a series of messages in queue that haven't arrived yet.
Can you try a different SMTP server?
In any event, good luck wth this.
FtB
Can you try a different SMTP server?
In any event, good luck wth this.
FtB
ASKER
Thanks ftb, They supplied me with a script which, surprisingly worked well:
<%
'Dimension variables
Dim objCDOSYSCon , objCDOSYSMail, Body
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.M essage")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuratio n = objCDOSYSCon
objCDOSYSMail.From = "[b]UserName@DomainName.co m[/b]"
objCDOSYSMail.To = "[b]UserName@DomainName.co m[/b]"
objCDOSYSMail.Subject = "[b]Your Subject[/b]"
Body = "Dear " + "User"+ ","
Body = Body + " <html>"
Body = Body + " <body>"
Body = Body + "<p>Your Mail script is working fine."
Body = Body + "...</p> "
Body = Body + "</body></html> "
objCDOSYSMail.HTMLBody = Body
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Response.Write("Your mail was sent")
%>
I didnt realise you need to use + instead of & in CDOSYS, either way for some reason this works although the other script is almost the same as my previous one which works at work - oh well - as we british like to call it, thats "Sods law"
Thanks for your time, this is another one for the bookmarks :o)
Have a great new year! Ciao for now
Apresto
<%
'Dimension variables
Dim objCDOSYSCon , objCDOSYSMail, Body
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.M
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuratio
objCDOSYSMail.From = "[b]UserName@DomainName.co
objCDOSYSMail.To = "[b]UserName@DomainName.co
objCDOSYSMail.Subject = "[b]Your Subject[/b]"
Body = "Dear " + "User"+ ","
Body = Body + " <html>"
Body = Body + " <body>"
Body = Body + "<p>Your Mail script is working fine."
Body = Body + "...</p> "
Body = Body + "</body></html> "
objCDOSYSMail.HTMLBody = Body
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Response.Write("Your mail was sent")
%>
I didnt realise you need to use + instead of & in CDOSYS, either way for some reason this works although the other script is almost the same as my previous one which works at work - oh well - as we british like to call it, thats "Sods law"
Thanks for your time, this is another one for the bookmarks :o)
Have a great new year! Ciao for now
Apresto
Actually, you don't. All VBScript variables are variants, so you can use + for concactonation instead of & if your items are clearly text strings. The important difference is this line:
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
You needed to use an IP for the SMTP server. This value varies from host to host.
FtB
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
You needed to use an IP for the SMTP server. This value varies from host to host.
FtB
ASKER
ah right, i notied that line had been added i just didnt realise what it was, thought it was an IP, wasnt sure who's.
Thanks again
Thanks again
Glad to have helped!
FtB
FtB
ASKER