CDO object working with Exchange Server 2003

G

Guest

Hello all,

I found the following function that sends emails through CDO object.
Does anyone knows how to change it in order to use exchange server for
sending/receiving emails?

Thank you in advance!

Public Function Email_CDO_Test()

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service
pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over
the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" <[email protected]>"
objMessage.To = "(e-mail address removed)"
objMessage.TextBody = "This is some sample message text.." & vbCrLf & "It
was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP
server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.mail.server"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a
connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

End Function
 
B

Baz

It'll work with any SMTP server, whether it's Exchange Server or something
else is irrelevant. Where it says "smtp.mail.server", just replace it with
the name of your Exchange Server.
 
G

Guest

First of all thank you for your answer.

I tried to use the name of my Exchange Server (and passwords) but i'm
getting the following error message "Run-time error '-2147220975 (80040211)':
The message could not be sent to the SMTP server. The transport error was
0x80040217. The server response was not available."

Any suggestions?
 
B

Baz

That is a log-on failure. The code you originally posted specifies basic
authentication but doesn't specify any logon credentials. Do you know
whether your Exchange Server requires you to authenticate? Try specifying
cdoAnonymous instead of cboBasic.
 
G

Guest

ok i will try this... thanks again!

Baz said:
That is a log-on failure. The code you originally posted specifies basic
authentication but doesn't specify any logon credentials. Do you know
whether your Exchange Server requires you to authenticate? Try specifying
cdoAnonymous instead of cboBasic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top