Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Contacts / January 2004

Tip: Looking for answers? Try searching our database.

Automating Outlook Contacts from Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leyland - 12 Jan 2004 03:00 GMT
Hi,
Are there any developers out there which know how to
programatically create contacts in Outlook from Access.  
I can create new contacts in the Contacts Default folder,
however I don't know how to move them into sub folders or
create them in different folders.

i.e This code creates a contact but how do I then move
the contact to a different folder

   'Create a Microsoft Outlook object.
   Set objOutlook = CreateObject("Outlook.Application")
   
   Set olns = objOutlook.GetNamespace("MAPI")
   Set cf = olns.GetDefaultFolder(olFolderContacts)
   'Create and open a new contact form for input.
   Set objItem = objOutlook.CreateItem(olContactItem)

   With objItem
       
       .MessageClass = "IPM.Contacts
       .FullName = "Leyland"
       .Phone = "9999 9999"

       .Save
       '.Close
       
   
   End With
   
   'Quit Microsoft Outlook.
   Set objOutlook = Nothing
   
Some help would be much appreciated.

Leyland
Sue Mosher [MVP] - 12 Jan 2004 13:23 GMT
If you want to store an item in a non-default folder, create it in that
folder with the MAPIFolder.Items.Add method instead of
Application.CreateObject. To get a non-default folder, you need to walk the
folder hierarchy using the Folders collections or use a function that does
that for you. See http://www.slipstick.com/dev/code/getfolder.htm

FYI, there is a newsgroup specifically for general Outlook programming
issues "down the hall" at microsoft.public.outlook.program_vba

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Hi,
> Are there any developers out there which know how to
[quoted text clipped - 31 lines]
>
> Leyland
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.