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?
pedropiedadeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.