Results 1 to 3 of 3

Thread: Open Outlook Folder by Path [Resolved]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522

    Open Outlook Folder by Path [Resolved]

    how can I open an outlook folder directly from its path.

    I need to open a folder that way down in the hiearchy.
    when I try the code below, it says it can't find it.

    VB Code:
    1. Private Sub CreateFolder()
    2. Dim olfolders As Outlook.Folders
    3. Dim fldr As MAPIFolder
    4. Dim olapp As New Outlook.Application
    5. Dim i As Long
    6.  
    7. Set olfolders = olapp.GetNamespace("MAPI").Folders
    8. Set fldr = olfolders.Item("Public folders\All Public Folders\Shared private Folders\Outlook Resource Calendars\Equipment\Mass Spectrometers")
    9. Debug.Print fldr.Name

    End Sub
    Last edited by Dalceon; Jul 29th, 2003 at 09:26 AM.
    It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.

  2. #2
    Hyperactive Member
    Join Date
    May 2002
    Location
    Omaha, NE
    Posts
    263
    Code:
    Public Sub SwitchToFolder()
         Dim olNS as NameSpace
    
         Set olNS=ThisOutlookSession.GetNameSpace("MAPI")
         Set ActiveExplorer.CurrentFolder = olNS.Folders(StoreName).Folders(FolderName)
    End Sub
    StoreName is the top-level Message Store, as in "Personal Folders".
    FolderName is the folder within that store that you want to open.


    P.S. To give credit where it is due, I found this on google

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    Thanks.

    I got impatient, and wrote my own function.

    VB Code:
    1. Private Function OpenOutlookFolder(FolderPath As String, Folders As Outlook.Folders) As MAPIFolder
    2. Dim tmparray As Variant
    3. Dim fldr As MAPIFolder
    4. Dim i As Integer
    5.  
    6. tmparray = Split(FolderPath, "\")
    7. Set fldr = Folders.Item(tmparray(0))
    8. For i = 1 To UBound(tmparray)
    9.    Set fldr = fldr.Folders.Item(tmparray(i))
    10. Next
    11.  
    12. Set OpenOutlookFolder = fldr
    13. Set fldr = Nothing
    14. End Function
    It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width