Solved

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

Posted on 2004-04-28
14
1,242 Views
Last Modified: 2010-05-18
**************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
Comment
Question by:tgatif
  • 6
  • 4
  • 2
  • +2
14 Comments
 
LVL 6

Expert Comment

by:MannSoft
ID: 10940052
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
 
LVL 31

Expert Comment

by:alorentz
ID: 10940094
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
 

Author Comment

by:tgatif
ID: 10940445
What kind of configurations do I need
0
 

Author Comment

by:tgatif
ID: 10940461
Please write the code for the configurations and their default values (if possible) other wise mention it.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10940471
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
 
LVL 31

Expert Comment

by:alorentz
ID: 10940597
Again, CDO is already programmed to use default configuration, so yu don't need to write any configuration...
0
 
LVL 1

Expert Comment

by:planetgrafx
ID: 10941651
*********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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:tgatif
ID: 10941666
But the code is giving me error.  The error said that "Send Using Configuration is Invalid"
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10941718
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
 

Author Comment

by:tgatif
ID: 10942391
Beg your pardon!

I used your code.  I just copied and pasted it and again giving me configuration error
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10942418
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
 
LVL 21

Accepted Solution

by:
ap_sajith earned 500 total points
ID: 10944415
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
 
LVL 31

Expert Comment

by:alorentz
ID: 10944727
@ap_sajith - I provided a link to configuraion settings...why did you feel the need to post same thing again?
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10946659
@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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now