CDO - How?

J

Jake

I'm looking to learn CDO, and my first very basic question: How do I make it run? I've keyed the following code into the Visual Basic editor (my first mistake?), and can't even start it due to MAPI.Session not being recognized. I have checked the references for "CDO for Windows 2000 Library" and "CDO for NTS 1.2 Library"...do I need any others?

Dim objSession As Mapi.Session
Dim objMessage As Message
Dim objOneRecip As Recipient

Set objSession = CreateObject("MAPI.Session")
objSession.Logon "MS Exchange Settings"

Set objMessage = objSession.outbox.Message.Add
objMessage.Subject = "Test Subject"
objMessage.Text = "Test text"

Set AddressList = objSession.AddressLists(1)
Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name = AddressList.AddressEntries(1)
objOneRecip.Type = 1
objOneRecip.Resolve

objMessage.Display
objMessage.Send False
objSession.Logoff


Thanks!
Jake
 
S

Sue Mosher [MVP]

Those are the wrong libraries. You need Collaboration Data Objects 1.21. It doesn't install by default, so you may need to rerun Outlook setup.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
D

Dmitry Streblechenko

MAPI.Session is a CDO 1.21 object. CDO 1.21 is an optional component
installed by Outlook or Exchange Server. Re-run Outlook setup, select
Custom, make sure "Collaboration Data Objects" is checked.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Jake said:
I'm looking to learn CDO, and my first very basic question: How do I make
it run? I've keyed the following code into the Visual Basic editor (my
first mistake?), and can't even start it due to MAPI.Session not being
recognized. I have checked the references for "CDO for Windows 2000
Library" and "CDO for NTS 1.2 Library"...do I need any others?
 

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