Open Outlook Folder from VB

How do you open a specific Folder from Outlook within VB?
Thank you.
AimyeeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AxterConnect With a Mentor Commented:
Sub fldrOpenTest()
OpenFolder "Inbox"
End Sub

Function OpenFolder(FldrName As String)
    Dim olApp As New Outlook.Application
    Dim nsMAPI As Outlook.NameSpace
    Set nsMAPI = olApp.GetNamespace("MAPI")
    Dim d As Long
    For d = 1 To nsMAPI.Folders.Count
        Dim p
        For p = 1 To nsMAPI.Folders.Item(d).Folders.Count
            If nsMAPI.Folders.Item(d).Folders.Item(p).Name = FldrName Then
                nsMAPI.Folders.Item(d).Folders.Item(p).Display 'This line can be removed
                Exit Function
                End If
            Next p
        Next d
End Function
0
All Courses

From novice to tech pro — start learning today.