2014-09-11 58 views
1

有沒有辦法通過擴展MAPI程序檢索特定Outlook配置文件的添加組信箱名稱?如何使用MAPI程序檢索Outlook配置文件的組郵箱名稱?

+0

你的代碼在哪裏運行?你已經有一個活動的MAPI會話?或者你只知道配置文件名稱? – 2014-09-11 15:28:21

+0

我有「配置文件名稱」。我想在Delphi中使用擴展MAPI程序獲取與特定配置文件鏈接的所有組郵箱名稱。 – user3801413 2014-09-12 05:59:15

+0

「鏈接」,如添加到Exchange提供程序選項對話框中的「打開這些額外的郵箱」?或者當前用戶有權打開的郵箱列表? – 2014-09-12 13:38:28

回答

1

我強烈建議使用Outlook Redemption,您可以通過Delphi調用COM。兌換附帶profman.dll,它允許您訪問Outlook配置文件。

下面是一些例子VBS代碼,我幾年前用來轉儲全部添加郵箱到一個XML文件(轉換爲德爾福不要太用力):

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 
1

您需要

  1. 呼叫MAPIAdminProfiles檢索IProfAdmin

  2. 呼叫IProfAdmin.AdminServices指定的文件名(找回ImsgServiceAdmin)

  3. 使用PR_SERVICE_NAME ==「MSEMS」查找服務(可以有多個)。

  4. 呼叫IMsgService.AdminProviders

  5. 查找 「EMSDelegate」 供應商。

你可以看到的數據,並在OutlookSpy發揮它(點擊IProfAdmin或在IMAPISession | AdminServices)。

相關問題