Long time ago, I had to retrieve the mailboxes configured in Outlook, allowing to select the right one.
It was not so easy to find the answer, so here it is
It was not so easy to find the answer, so here it is
Code:
Public Sub Outlook_DisplayAllMailbox()
' #VBIDEUtils#***********************************************************
' * Author :
' * Web Site :
' * E-Mail :
' * Date : 01/24/2007
' * Time : 13:42
' * Module Name : Outlook_Module
' * Module Filename : Outlook.bas
' * Procedure Name : Outlook_DisplayAllMailbox
' * Purpose :
' * Parameters :
' * oSelect As Control
' * Purpose :
' **********************************************************************
' * Comments :
' *
' *
' * Example :
' *
' * See Also :
' *
' * History :
' *
' *
' **********************************************************************
' #VBIDEUtilsERROR#
On Error GoTo ERROR_Outlook_DisplayAllMailbox
Dim objOutlook As Object
Dim nI As Long
Set objOutlook = CreateObject("Outlook.Application")
On Error Resume Next
For nI = 1 To objOutlook.session.Accounts.Count
Debug.Print objOutlook.session.Accounts.Item(nI)
Next
On Error GoTo ERROR_Outlook_DisplayAllMailbox
EXIT_Outlook_DisplayAllMailbox:
On Error Resume Next
Set objOutlook = Nothing
Exit Sub
' #VBIDEUtilsERROR#
ERROR_Outlook_DisplayAllMailbox:
If Err.Number = -2147467259 Then
MsgBox Error, vbInformation
Resume Next
End If
Resume EXIT_Outlook_DisplayAllMailbox
Resume
End Sub