1

I am trying set a reference to a non-default inbox in MS Outlook. I have found a code in SO,

Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Set objNS = GetNamespace("MAPI")
Set objFolder = objNS.Folders("Procurement, Request")
Set objFolder = objFolder.Folders("Inbox")

which is OK when inbox is named "Inbox".

There is a possibility for inboxes to be named in non-English languages.

You may refer to the default inbox by

objNS.getdefaultfolder(6)

But what about non-defaults?

Community
  • 1
  • 1
MarcinSzaleniec
  • 2,246
  • 1
  • 7
  • 22

1 Answers1

1

You should be able to get inboxes by Store index or name.

Option Explicit

Sub Inbox_by_Store()

Dim allStores As Stores
Dim storeInbox As Folder

Dim i As Long

Set allStores = Session.Stores

For i = 1 To allStores.count

    Debug.Print i & " DisplayName - " & allStores(i).DisplayName

    Set storeInbox = Nothing
    On Error Resume Next
    Set storeInbox = allStores(i).GetDefaultFolder(olFolderInbox)
    On Error GoTo 0

    If Not storeInbox Is Nothing Then
        storeInbox.Display
    End If

Next

ExitRoutine:
    Set allStores = Nothing
    Set storeInbox = Nothing

End Sub
niton
  • 8,771
  • 21
  • 32
  • 52