1

有没有办法通过 VBA 提取此对话框中的详细信息?

详细信息对话框 http://i.msdn.microsoft.com/dynimg/IC84336.gif

我需要,尤其是电子邮件地址选项卡中的内容。

4

3 回答 3

2

您几乎可以轻松获取这些字段,电子邮件地址是更难的部分。参考:Microsoft Exchange 属性标签

此代码将一些详细信息(但最重要的是电子邮件地址)导出到文本文件。

Sub ListGAL()
    On Error Resume Next
    Const LogFile = "C:\Test\OLK_GAL.log"
    Const sSCHEMA = "http://schemas.microsoft.com/mapi/proptag/0x"
    Const PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

    Dim oNameSpace As NameSpace, oGAL As AddressList, oEntry As AddressEntry
    Dim oFSO As Variant, oLF As Variant, oExUser As ExchangeUser, i As Long

    ' Oulook objects
    Set oNameSpace = Outlook.Application.GetNamespace("MAPI")
    ' Global Address List object
    Set oGAL = oNameSpace.AddressLists("Global Address List")
    '----------
    ' Log file objects
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oLF = oFSO.CreateTextFile(LogFile)
    '----------
    For Each oEntry In oGAL.AddressEntries
        i = i + 1
        Debug.Print i & vbTab & oEntry.Name
        If oEntry.AddressEntryUserType = olExchangeUserAddressEntry Then
            oLF.WriteLine "Entry " & i & " (olExchangeUserAddressEntry)"
            oLF.WriteLine "Name: " & oEntry.Name
            oLF.WriteLine "Address: " & oEntry.Address
            Set oExUser = oEntry.GetExchangeUser
            ' SMTP ADDRESSES
            oLF.WriteLine "SMTP Addresses:"
            oLF.WriteLine vbTab & Join(oExUser.PropertyAccessor.GetProperty(sSCHEMA & Hex(PR_EMS_AB_PROXY_ADDRESSES)), vbCrLf & vbTab)
            Set oExUser = Nothing
            oLF.WriteLine String(50, Chr(151)) ' Separator
        End If
    Next
    '----------
    ' Close Log File, clean up
    oLF.Close
    Set oGAL = Nothing
    Set oNameSpace = Nothing
    Set oLF = Nothing
    Set oFSO = Nothing
End Sub
于 2013-10-14T02:28:55.493 回答
1

我有一个阅读地址簿的功能:

Function Get_mail(Absender As String)
Dim OutApp As Outlook.Application
Dim OutTI As Outlook.TaskItem
Dim OutRec As Outlook.Recipient

  Set OutApp = New Outlook.Application
  Set OutTI = OutApp.CreateItem(3)
  OutTI.Assign

  Set OutRec = OutTI.Recipients.Add(Absender)
  OutRec.Resolve

   If OutRec.Resolved Then
    On Error GoTo exit_function
        Get_mail = OutRec.AddressEntry.GetExchangeUser.PrimarySmtpAddress
   End If
exit_function: Exit Function
  Set OutApp = Nothing
  Set OutTI = Nothing
End Function

据我所知,您只能从邮件地址选项卡中读出主邮件地址;看看还有什么删除部分“.PrimarySmtpAddress”,mahe 点,你应该得到其他属性的列表。

我很确定您需要有关 Microsoft Outlook 14.0 对象库的参考。

输入“Absender”可以是任何字符串。如果可以将此字符串解析为 Outlook 邮件中的地址簿条目,则上述代码也会得到肯定的结果。要调用该函数,例如,如果您有一个字符串“mail_adress_from_adressbook”,您可以输入:

mail_adress_from_adressbook = get_mail("Joe Smith")

我希望这会有所帮助,马克斯

于 2013-10-07T16:42:02.507 回答
0

当然,使用AddressEntry.PropertyAccessor.GetProperty.

DASL 属性名称可以使用OutlookSpy检索:单击 IAddrBook 按钮以深入查看特定地址条目,或者,如果您有一封发送给 GAL 收件人的邮件,请单击 IMessage 按钮,转到 GetRecipientTable 选项卡,双击收件人以 IMailUser 身份打开它。

于 2013-10-06T18:55:04.620 回答