A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

setting my code to access contacts from a a different folder.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 1st 06, 04:33 AM posted to microsoft.public.outlook.program_vba
Charlie
external usenet poster
 
Posts: 68
Default setting my code to access contacts from a a different folder.

Here is the beginning of some code I'm using:
' Set up DAO objects (uses existing "Contacts" table)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Outlook Contacts")

' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
Set objItems = cf.Items
iNumContacts = objItems.Count
If iNumContacts 0 Then
For I = 1 To iNumContacts
If TypeName(objItems(I)) = "ContactItem" Then
Set c = objItems(I)
If c.Categories = strCategory Then 'It's one of the right category


My question is which part of this do I need to change if I want to access
contacts in a different folder? In Outlook, I have a folder called Work
Contacts, it's not a sub folder to "Contacts" it's just another folder in the
list where it says Contacts, Inbox, Outbox, etc... I'd like to access these
contact items directly, rather than having to always move them to my regular
Contact folder to access them.
thanks,
ck

Ads
  #2  
Old May 1st 06, 01:45 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default setting my code to access contacts from a a different folder.

To get a non-default folder, instead of GetDefaultFolder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Charlie" wrote in message ...
Here is the beginning of some code I'm using:
' Set up DAO objects (uses existing "Contacts" table)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Outlook Contacts")

' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
Set objItems = cf.Items
iNumContacts = objItems.Count
If iNumContacts 0 Then
For I = 1 To iNumContacts
If TypeName(objItems(I)) = "ContactItem" Then
Set c = objItems(I)
If c.Categories = strCategory Then 'It's one of the right category


My question is which part of this do I need to change if I want to access
contacts in a different folder? In Outlook, I have a folder called Work
Contacts, it's not a sub folder to "Contacts" it's just another folder in the
list where it says Contacts, Inbox, Outbox, etc... I'd like to access these
contact items directly, rather than having to always move them to my regular
Contact folder to access them.
thanks,
ck

  #3  
Old May 1st 06, 05:23 PM posted to microsoft.public.outlook.program_vba
Charlie
external usenet poster
 
Posts: 68
Default setting my code to access contacts from a a different folder.

Set objFolder = GetFolder("Public Folders/All Public Folders/Company/Sales")

Hi again. My folder "Work Contacts" is in the list with the other outlook
items, like Contacts, Calendar, Inbox, etc. I haven't made any other
folders, and when I click the properties of "Work Contacts" is says the
location is \\Personal Folders.
So should I use
Set objFolder = GetFolder("Public Folders/Personal Folders\Work Contacts")?
thanks,
ck
  #4  
Old May 1st 06, 06:26 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default setting my code to access contacts from a a different folder.

Look in the Folder List navigation pane. The path to the folder in question needs to ***exactly*** match the names of the branches in its hierarchy, just like the path to a file in the file system. Why would you include Public Folders if It's not a part of the hierarchy above Work Contacts?

Also, if you have Outlook Spy and Outlook 2002 or later, you can check the value of the FolderPath property.

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

"Charlie" wrote in message ...
Set objFolder = GetFolder("Public Folders/All Public Folders/Company/Sales")

Hi again. My folder "Work Contacts" is in the list with the other outlook
items, like Contacts, Calendar, Inbox, etc. I haven't made any other
folders, and when I click the properties of "Work Contacts" is says the
location is \\Personal Folders.
So should I use
Set objFolder = GetFolder("Public Folders/Personal Folders\Work Contacts")?
thanks,
ck

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to put in Access that will send an Email with Attachments [email protected] Outlook and VBA 1 April 9th 06 06:30 PM
Outlook not displaying attachment from Access via code [email protected] Outlook - General Queries 4 February 28th 06 12:30 AM
how to do coding in ms access 2000 and setting different properti saif Outlook - Using Forms 1 February 10th 06 01:57 PM
Link Access Table to Exchange Public Folder Contacts Brian Outlook - Using Contacts 0 January 29th 06 09:05 PM
Running query from Access Form commmand using VBA code Berny Outlook and VBA 4 January 16th 06 03:12 PM


All times are GMT +1. The time now is 12:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.