Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1281
  • Last Modified:

Problem with CDONTS ***** ERROR The "SendUsing" configuration value is invalid. *****

**************QUESTION*****************
I have the simple code given below.  It is giving me the following error.  Please tell me the resolution

****************CODE*******************
Set cdoConfig = CreateObject("CDO.Configuration")  
Set cdoMessage = CreateObject("CDO.Message")  
 
With cdoMessage
        Set .Configuration = cdoConfig
        .From = "mtaj@ekinsystems.com"
        .To = "mtaj@ekinstems.com"
        .Subject = "Sample CDO Message"
        .TextBody = "This is a test for CDO.message"
        .Send
End With
 
Set cdoMessage = Nothing  
Set cdoConfig = Nothing  

****************ERROR****************
CDO.Message.1 error '80040220'

The "SendUsing" configuration value is invalid.


0
tgatif
Asked:
tgatif
  • 6
  • 4
  • 2
  • +2
1 Solution
 
MannSoftCommented:
I have the same problem here.  On my production server, CDO.Message works fine.  On my test machine, I get the error you've shown.  I never really looked deep into the problem, but if I had to guess it's probably because on my test machine there is no SMTP server, but on my production server there is.  So on the production server it uses the SMTP server from the same machine, and on my test server, it has to be told where to send to.

The reason I never looked for the real problem is because I found CDONTS.NewMail worked on both machines, so I just started using it instead.  If that's not an option, you could look at this old post:

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20780859.html
0
 
alorentzCommented:
You definitely need an SMTP server, and if it's not on the local machine you will need to use configuration.  If you have SMTP running with IIS on local machine, which you should, you don't need configuration:

Default settings work fine...

Set cdoMessage = CreateObject("CDO.Message")  
 
With cdoMessage
        .From = "mtaj@ekinsystems.com"
        .To = "mtaj@ekinstems.com"
        .Subject = "Sample CDO Message"
        .TextBody = "This is a test for CDO.message"
        .Send
End With
 
Set cdoMessage = Nothing  


0
 
tgatifAuthor Commented:
What kind of configurations do I need
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tgatifAuthor Commented:
Please write the code for the configurations and their default values (if possible) other wise mention it.
0
 
alorentzCommented:
Like I said, none...

Do you have the SMTP server on the webserver...or do you need to use SMTP realy on a nother server?
0
 
alorentzCommented:
Again, CDO is already programmed to use default configuration, so yu don't need to write any configuration...
0
 
planetgrafxCommented:
*********FIRST USE THIS************************
Validate that CDONTS.NewMail is installed

*********TESTOBJECT.ASP***********************

<% @ Language="VBScript" %>
<% Option Explicit %>
<%
' there are a number of objects that come with IIS4
' these are put in the array that's declared below
Dim theInstalledObjects(10)

theInstalledObjects(0) = "MSWC.AdRotator"
theInstalledObjects(1) = "MSWC.BrowserType"
theInstalledObjects(2) = "MSWC.NextLink"
theInstalledObjects(3) = "MSWC.Tools"
theInstalledObjects(4) = "MSWC.Status"
theInstalledObjects(5) = "MSWC.Counters"
theInstalledObjects(6) = "IISSample.ContentRotator"
theInstalledObjects(7) = "IISSample.PageCounter"
theInstalledObjects(8) = "MSWC.PermissionChecker"
theInstalledObjects(9) = "SoftArtisans.FileUp"
theInstalledObjects(10) = "CDONTS.NewMail"

Function IsObjInstalled(strClassString)
 On Error Resume Next
 ' initialize default values
 IsObjInstalled = False
 Err = 0
 ' testing code
 Dim xTestObj
 Set xTestObj = Server.CreateObject(strClassString)
 If 0 = Err Then IsObjInstalled = True
 ' cleanup
 Set xTestObj = Nothing
 Err = 0
End Function
%>

<HTML>
<HEAD>
<TITLE>Test of installed objects</TITLE>
</HEAD>
<BODY>

Enter the ProgId or ClassId of the component you want to test in the textbox below. If you leave it empty, the default
components will be tested.

<FORM action=<%=Request.ServerVariables("SCRIPT_NAME")%> method=post>
<input type=text value="" name="classname" size=40>
<INPUT type=submit value=Submit>
<INPUT type=reset value=Reset>
</FORM>

<%
Dim strClass
strClass = Trim(Request.Form("classname"))
If "" <> strClass then
  Response.Write strClass & " is "
  If Not IsObjInstalled(strClass) then
    Response.Write "<strong>not installed</strong>"
  Else
    Response.Write "installed!"
  End If
  Response.Write "<P>" & vbCrLf
Else
  ' default: list all components that should be installed
%>

<TABLE BORDER=0>
<%
Dim i
For i=0 to UBound(theInstalledObjects)
  Response.Write "<TR><TD>" & theInstalledObjects(i) & "</TD><TD>"
  If Not IsObjInstalled(theInstalledObjects(i)) Then
    Response.Write "<strong>not installed</strong>"
  Else
    Response.Write "installed!"
  End If
  Response.Write "</TD></TR>" & vbCrLf
Next
%>
</TABLE>

<%
End If
%>

</BODY>
</HTML>

****************THEN USE THIS**************************
DO NOT Leave the FROM field blank or it wont come to your email address

****************TESTMAIL.ASP***************************
<%
If Request.Form.Count > 0 Then
    For I = 1 to Request.Form.Count
        Body = Body & Request.Form.Key(I) & " " _
               & Request.Form.Item(I) & vbCRLF
    Next
   
strTo = Request("to")
strFrom = Request("from")
strSubject = Request("subject")
strBody = Request("body")
   
   
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From =strFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
objCDOMail.Send
Set objCDOMail = Nothing


    Response.Write "E-Mail Sent!"
End If
%>
<html>
<head>
<title>E-mailer</title>
</head>

<body>

<table border="0" cellpadding="2" width="620">
  <form method="POST" action="<%= Request.ServerVariables("SCRIPT_NAME") %>">
      <tr>
      <td><b><font size="2" face="Verdana"> E-mail&nbsp;From</font></b></td>
      <td><input type="text" name="from" size="30"></td>
    </tr>
    <tr>
      <td><b><font size="2" face="Verdana">E-mail&nbsp;To</font></b></td>
      <td><input type="text" name="to" size="30"></td>
    </tr>
    <tr>
      <td><b><font size="2" face="Verdana">Subject</font></b></td>
      <td><input type="text" name="subject" size="45"></td>
    </tr>
    <tr>
      <td valign="top"><b><font size="2" face="Verdana">Body</font></b><p>&nbsp;</p>
      <p>&nbsp;</td>
      <td><textarea rows="15" name="body" cols="50"></textarea></td>
    </tr>
    <tr>
      <td align="center" colspan="2">
      <p align="center"><b><font size="2" face="Verdana"><input type="submit" value="Send E-Mail"></font></b></td>
    </tr>
  </form>
</table>

</body>

</html>



****************IF THE ABOVE DOESN'T WORK**************************
Validate that SMTP is working

http://www.iis-resources.com/modules/news/article.php?storyid=5


BTW: What OS is the Machine? Is it 2000, XP, 2003 ?





0
 
tgatifAuthor Commented:
But the code is giving me error.  The error said that "Send Using Configuration is Invalid"
0
 
alorentzCommented:
It's really not productive to dispute what I tell you...have you tried my code.  The error you had was because you initailize configuration but never added any configuration information.

Just use my code...NO CONFIGURATION
0
 
tgatifAuthor Commented:
Beg your pardon!

I used your code.  I just copied and pasted it and again giving me configuration error
0
 
alorentzCommented:
So then your SMTP is not set up properly....that is what I asked before.

See here:  CDO with Config...

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20779650.html?query=cdo+configuration&searchType=topic
0
 
ap_sajithCommented:
Try this code.. see if it works...


<%
Call SendMailCDOSYS("you@domain.com","you1@domain.com","TestMail","this is a test mail",False,"localhost")
' ** YOU CAN SPECIFY ANY MAIL SERVER AS THE LAST PARAMETER AS LONG AS IT IS VALID. **

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer)
On Error Resume Next
      Dim objCDOConf,objCDOSYS
      ' ** CREATE THE E-MAIL SERVER OBJECT **
      Set objCDOSYS = Server.CreateObject("CDO.Message")
      Set objCDOConf = Server.CreateObject ("CDO.Configuration")

      ' ** SET AND UPDATE FIELDS PROPERTIES **
      With objCDOConf
            ' ** OUT GOING SMTP SERVER **
            .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
            ' ** SMTP PORT **
            .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
            ' ** CDO PORT **
            .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            ' ** TIMEOUT **
            .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
            .Fields.Update
      End With

      ' ** UPDATE THE CDOSYS CONFIGURATION **
      Set objCDOSYS.Configuration = objCDOConf

      With objCDOSYS    
            ' ** WHO THE E-MAIL IS FROM **
            .From = strFrom

            ' ** WHO THE E-MAIL IS SENT TO **
            .To = strTo
                        
            ' ** THE SUBJECT OF THE E-MAIL **
            .Subject = strSubject
             
            ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
            If blnHTML = True Then
            .HTMLBody = strMailBody
            Else
            .TextBody = strMailBody
            End If
             
            ' ** SEND THE E-MAIL **
            .Send
      End with                    
        
      ' ** CLOSE THE SERVER MAIL OBJECT **
      Set objCDOSYS = Nothing
End Sub
%>

Also, Your error might be caused because you are creating your configuration object before setting the message object. Try reversing that in your code as well.

Also, as Alorentz already pointed out, make sure that the SMTP is configured and your machine is connected to the network.

Hope this helps...

Cheers!!
0
 
alorentzCommented:
@ap_sajith - I provided a link to configuraion settings...why did you feel the need to post same thing again?
0
 
ap_sajithCommented:
@alorentz, I just posted a tried and tested code that i use in my apps. I was in a hurry and didnt really check out the URl that you posted. Besides,i think he would get an error because he tried setting the configuration before setting the message object. Sorry if i offended you in any way. BTW... great going...keep up the good work!.

Cheers!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now