'How to retrive Group mail box names for outlook profile using MAPI program?
Is there a way to retrieve added group mail boxes name for particular outlook profile through extended MAPI program?
Solution 1:[1]
I would strongly advise to go with Outlook Redemption which you can call with COM from Delphi. Redemption comes with profman.dll which gives you access to Outlook profiles.
Here's some example VBS code that I used a couple of years ago to dump all added mailboxes to an xml file (conversion to Delphi should not be too hard):
Option Explicit
Dim fso, WshShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
WshShell.CurrentDirectory = fso.GetParentFolderName(WScript.ScriptFullName)
' Load TXMLDocument Class
Include("XMLClass.vbs")
' MAPI constanten
Const PR_DISPLAY_NAME = &H3001001E
Const PR_DISPLAY_NAME_W = &H3001001F
Const PR_MDB_PROVIDER = &H34140102
Const PR_PROFILE_HOME_SERVER = &H6602001E
Const PR_PROFILE_HOME_SERVER_DN = &H6612001E
Const PR_PROFILE_MAILBOX = &H660B001E
Const PR_PROFILE_SERVER = &H660C001E
Const PR_PROFILE_SERVER_DN = &H6614001E
Const PR_PROFILE_UNRESOLVED_NAME = &H6607001E
Const PR_PROFILE_UNRESOLVED_SERVER = &H6608001E
Const PR_PROFILE_USER = &H6603001E
Const PR_PST_PATH = &H6700001E
Const PR_SERVICE_UID = &H3D0C0102
Const PR_STORE_PROVIDERS = &H3D000102
' GUID constanten
Const MailboxGuid = "13DBB0C8AA05101A9BB000AA002FC45A"
Const pbExchangeProviderDelegateGuid = "9EB4770074E411CE8C5E00AA004254E2"
' omgevingsspecifieke gegevens
Const cHomeFolder = "U:\"
' public variabelen
Public objProfiles, objProfile, objServices, objExchService
' XML Object
Dim xmlDoc
Set xmlDoc = New TXMLDocument
xmlDoc.Create("delegateMailboxes")
'Profman object aanmaken (profman.dll, moet in de c:\windows\system32 map staan, registreren met regsvr32)
Set objProfiles = CreateObject("ProfMan.Profiles")
' Open Default Outlook Profile
Set objProfile = objProfiles.DefaultProfile
Set objServices = objProfile.Services
' Zoek Exchange Service
Dim ServiceIndex, objService, objProviders, ProviderIndex, objProvider, objProfSect
For ServiceIndex = 1 To objServices.Count
Set objService = objServices.Item(ServiceIndex)
If objService.ServiceName = "MSEMS" Then
Set objProviders = objService.Providers
For ProviderIndex = 1 To objProviders.Count
Set objProvider = objProviders.Item(ProviderIndex)
Set objProfSect = objProvider.ProfSect
' Gekoppelde mailboxen gebruiken de Exchange Delegate Provider
If objProfSect.Item(PR_MDB_PROVIDER) = pbExchangeProviderDelegateGuid Then
xmlDoc.AddRecord("delegateMailbox")
Call xmlDoc.AddElement("PR_DISPLAY_NAME", objProvider.DisplayName)
Call xmlDoc.AddElement("PR_DISPLAY_NAME_W", objProvider.DisplayName)
Call xmlDoc.AddElement("PR_PROFILE_MAILBOX", objProfSect.Item(PR_PROFILE_MAILBOX))
Call xmlDoc.AddElement("PR_PROFILE_SERVER", objProfSect.Item(PR_PROFILE_SERVER))
Call xmlDoc.AddElement("PR_PROFILE_SERVER_DN", objProfSect.Item(PR_PROFILE_SERVER_DN))
End If
Next
End If
Next
xmlDoc.SaveFormatted(cHomeFolder & "\delegateMailboxes.xml")
xmlDoc.Free
Set xmlDoc = Nothing
WScript.Quit(0)
Function Include (Scriptname)
Dim fso, objFile
Err.Clear
Set fso = CreateObject("Scripting.FileSystemObject")
Scriptname = fso.GetParentFolderName(WScript.ScriptFullName) & "\" & Scriptname
' WScript.Echo("Including " & Scriptname)
Set objFile = fso.OpenTextFile(Scriptname)
ExecuteGlobal(objFile.ReadAll())
objFile.Close
Include = Err.Number
End Function
Solution 2:[2]
You will need to
Call MAPIAdminProfiles to retrieve IProfAdmin
Call IProfAdmin.AdminServices specifying the profile name (get back ImsgServiceAdmin)
Find the service with PR_SERVICE_NAME == "MSEMS" (there can be more than one).
Call IMsgService.AdminProviders
Find "EMSDelegate" providers.
You can see the data and play with it in OutlookSpy (I am its author) - click IProfAdmin or IMAPISession | AdminServices.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Remko |
Solution 2 |