Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CDO to create new address book 1

Status
Not open for further replies.

bigaustin

Programmer
Jul 23, 2002
7
US
Here's the scenario: I can create a new MAPI folder through CDO, but it defaults to be a "Mail and Post Items" type folder (i.e. will hold e-mail), whereas I want it to be a "Contact Items" type folder. Any suggestions?

Here's the basic code:

Set Session = CreateObject("MAPI.Session")
Session.Logon

Set Contacts = Session.GetDefaultFolder(5)
Set newFolder = Contacts.Folders.Add("New Book")
 
I had the same problem, so I tried until I got it working.

Dim oOutLook As Object

Set oOutLook = CreateObject("Outlook.Application")
Set myNameSpace = oOutLook.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
Set newFolder = myFolder.Folders.Add("New Book")


Maybe Outlook's implementation of MAPI causes the problem with CDO. Go figure!

I'll try it on a box that doesn't have Outlook.
'We all must do the hard bits so when we get bit we know where to bite' :)
 
Very helpful indeed! Thank you.

Now, if I can only figure out how to set my new address book as an "Outlook Address Book" (so that it is returned in a list of MAPI Address Books).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top