• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7685
  • Last Modified:

CDO "SendUsing" Error

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
pedropiedade
Asked:
pedropiedade
1 Solution
 
dukestaTAICommented:
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
 
dukestaTAICommented:
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
 
Saqib KhanSenior DeveloperCommented:
replace

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

 objMail = Server.CreateObject("CDONTS.NewMail");
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
pedropiedadeAuthor Commented:
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
 
dukestaTAICommented:
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
 
dukestaTAICommented:
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
 
ZargothCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now