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 / Programming VBA / May 2005

Tip: Looking for answers? Try searching our database.

Trying to access custom folders in other mailboxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jack - 25 May 2005 08:27 GMT
I tried using the following code to access custom subfolders in another
users shared mailbox
however it returns an empty object, what am I doing wrong ?? (outlook 2003)

thanx for help in advance, Jack

Public Function GetSharedFolder(strFolderPath As String) As MAPIFolder
 ' folder path needs to be something like
 '   "Sales Department\Company\Sales"
 ' where first folder in path is the shared mailbox's fully resolvable name
 Dim objApp As Outlook.Application
 Dim objNS As Outlook.NameSpace
 Dim colFolders As Outlook.Folders
 Dim objFolder As Outlook.MAPIFolder
 Dim myRecipient As Outlook.Recipient
 Dim arrFolders() As String
 Dim I As Long
 On Error Resume Next

 strFolderPath = Replace(strFolderPath, "/", "\")
 arrFolders() = Split(strFolderPath, "\")
 Set objApp = CreateObject("Outlook.Application")
 Set objNS = objApp.GetNamespace("MAPI")
 Set myRecipient = objNS.CreateRecipient(arrFolders(0))
 Set objFolder = _
   objNS.GetSharedDefaultFolder(myRecipient, olFolderSharedRoot)
 If Not objFolder Is Nothing Then
   For I = 1 To UBound(arrFolders)
     Set colFolders = objFolder.Folders
     Set objFolder = Nothing
     Set objFolder = colFolders.Item(arrFolders(I))
     If objFolder Is Nothing Then
       Exit For
     End If
   Next
 End If

 Set GetSharedFolder = objFolder
 Set colFolders = Nothing
 Set objNS = Nothing
 Set objApp = Nothing
End Function
Sue Mosher [MVP-Outlook] - 25 May 2005 12:44 GMT
You can only use GetSharedDefaultFolder to return default folders from another mailbox. To get subfolders, you need to walk the folder hierarchy, starting with the top-level of the mailbox. You can use the original GetFolder() function, from which you apparently developed the function below.
Signature

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

>I tried using the following code to access custom subfolders in another
> users shared mailbox
[quoted text clipped - 38 lines]
>  Set objApp = Nothing
> End Function
jack - 27 May 2005 07:18 GMT
I got it working by using the GetFolder function and using the full folder
heirarchy
eg to access the folder Folder/SubFolder in mailbox Sales Dept, used the
following GetFolder("mailbox - Sales Dept/Folder/SubFolder")
needed the "mailbox - " in front of the mailbox user name for it to work

thanx, jack

You can only use GetSharedDefaultFolder to return default folders from
another mailbox. To get subfolders, you need to walk the folder hierarchy,
starting with the top-level of the mailbox. You can use the original
GetFolder() function, from which you apparently developed the function
below.
Signature

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

>I tried using the following code to access custom subfolders in another
> users shared mailbox
[quoted text clipped - 40 lines]
>  Set objApp = Nothing
> End Function
 
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.