Solved

CDO "SendUsing" Error

Posted on 2003-10-28
7
7,610 Views
Last Modified: 2007-12-19
I have this code to send email:

objMail = Server.CreateObject("CDO.Message");
objMail.To = "pedro@nitrgenio.net";
objMail.From = "pedro@galactica.pt";
objMail.Subject = "CDO Sample";
objMail.TextBody = "This is a test email using CDO";
objMail.Send();

and I get  this "SendUsing" error...

What's wrong?
0
Comment
Question by:pedropiedade
7 Comments
 
LVL 4

Expert Comment

by:dukestaTAI
ID: 9636927
Try this

DIM iMsg, Flds, iConf

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .Configuration = iConf
.To = "pedro@nitrgenio.net"
.From = "pedro@galactica.pt"
.Subject = "CDO Sample"
.HTMLBody = "This is a test email using CDO"
.Send
End With
0
 
LVL 4

Expert Comment

by:dukestaTAI
ID: 9636943
Try this

DIM iMsg, Flds, iConf

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "REPLACE_WITH_IP_OF_YOUR_SMTP_SERVER"
Flds(cdoSMTPServerPort) = 25
Flds(cdoSMTPAuthenticate) = cdoAnonymous ' 0
Flds.Update

With iMsg
Set .Configuration = iConf
.To = "pedro@nitrgenio.net"
.From = "pedro@galactica.pt"
.Subject = "CDO Sample"
.HTMLBody = "This is a test email using CDO"
.Send
End With
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 9637585
replace

 > objMail = Server.CreateObject("CDO.Message");
with

 objMail = Server.CreateObject("CDONTS.NewMail");
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:pedropiedade
ID: 9641010
Please note that I'm useing Javascript.
I tried this:

      objMail = Server.CreateObject("CDO.Message");
      iConf = Server.CreateObject("CDO.Configuration");

      iConf.Fields("cdoSendUsingMethod") = "cdoSendUsingPort";
      iConf.Fields("cdoSMTPServer") = "169.254.173.128";
      iConf.Fields("cdoSMTPServerPort") = 25;
      iConf.Fields("cdoSMTPAuthenticate") = 0;
      iConf.Fields.Update();

      objMail.Configuration = iConf;
      objMail.To = "pedro@nitrgenio.net";
      objMail.From = "pedro@galactica.pt";
      objMail.Subject = "CDO Sample";
      objMail.TextBody = "This is a test email using CDO";
      objMail.Send();

But got the same error:

Tipo de erro:
CDO.Message.1 (0x80040220)
O valor de configuração "SendUsing" é inválido.
/sites/cdomail.asp, linha 43

(something like "The configuration value for "SendUsing" is not valid")

Any ideas?
0
 
LVL 4

Expert Comment

by:dukestaTAI
ID: 9641259
Are you using Windows NT or 2000.

If you are using NT it would be CDONTS.

If you are using 2000 it would be CDO.
0
 
LVL 4

Accepted Solution

by:
dukestaTAI earned 50 total points
ID: 9641358
The error you are getting is a permission error.  The account you are using to send the message does not have sufficient rights to send the message.

This might help.

2.  Code Modification
In the case where a code modification is the preferred workaround, there are two ways of accomplishing the modification. You can use either cdoSendUsingPickup or cdoSendUsingPort.
2a.  cdoSendUsingPickup
Because cdoSendUsingPickup is the default value, it does not need to be specified; however, explicitly specifying it would make your code easier to read. The pickup directory does need to be specified.

Advantages
·      Greater application control of configuration.
·      Not restricted to first SMTP service instance.
Disadvantages
·      More fragile – installation of Exchange or administration configuration changes may cause the application to quit working because of changes to the location of the pickup directory.
·      Must configure local SMTP for relay.


Sample
The following code sample demonstrates setting cdoSendUsingPickup and the pickup directory’s location:

<%@ Language=VBScript %>
<%
   Dim iMsg
   Dim iConf
   Dim Flds  
   Const cdoSendUsingPickup = 1
   'For CDOSYS, the pickup directory is located at c:\inetpub\mailroot\pickup
   Const strPickup = "c:\Program Files\Exchsrvr\mailroot\vsi 1\Pickup"  

   'Create the message object
   Set iMsg = CreateObject("CDO.Message")  
   'Create the configuration object
   Set iConf = iMsg.Configuration  
   With iConf.Fields
      .item( "http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
      .item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = strPickup
      .Update
   End With
   'Set the message to,from,subject,body properties.
   With iMsg
      .To = "packerman@adatum.com"
      .From = "mbaker@adatum.com"
      .Subject = "Test message using CDOEx and cdoSendUsingPickup sent on: "  & now()
      .TextBody = "This is a test using CDOEx"
      .Send
   End With
   Set iMsg = Nothing
%>
 
0
 

Expert Comment

by:Zargoth
ID: 10105427
Ok,
Sendusing takes a number as a parameter not a string so "cdoSendUsingPort"; should be cdoSendUsingPort (which is a variable in a list you've included in your ASP file) or you could use the number 2 for the same option.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Classic ASP, Search Recordset on pick list change 1 71
SP to delete duplicates 15 73
Choose the older file FSO 6 50
One field not displaying content (ASP Classic) 8 31
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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