Vba 如何从/o=ExchangeLabs/ou=Exchange管理组获取电子邮件地址。。。?

Vba 如何从/o=ExchangeLabs/ou=Exchange管理组获取电子邮件地址。。。?,vba,outlook,Vba,Outlook,我正在尝试通过Outlook VBA宏自动发送电子邮件并复制会议组织者。我的公司正在使用Office 365 我正在使用item.GetOrganizer元素获取组织者的名称 Debug.Print oItem.GetOrganizer.Address提供: /o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=c035bc5647d64d89aecbc6d3ddb5580b-Nam

我正在尝试通过Outlook VBA宏自动发送电子邮件并复制会议组织者。我的公司正在使用Office 365

我正在使用
item.GetOrganizer
元素获取组织者的名称

Debug.Print oItem.GetOrganizer.Address
提供:

/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=c035bc5647d64d89aecbc6d3ddb5580b-Name
如何获取电子邮件地址?

示例


你有预约的物品吗?也许是贴在程序员身上的。看起来您的代码中已将AppointItem存储为
item
。GetOrganizer返回具有Address属性的AddressEntry对象。类似于
item.GetOrganizer.Address的内容应该显示电子邮件地址。未测试,但链和属性存在。对于我来说,调试。打印oItem.GetOrganizer.Address/o=ExchangeLabs/ou=Exchange管理组(FYDIBOHF23SPDLT)/cn=Recipients/cn=c035bc5647d64d89aecbc6d3ddb5580b名称-不是电子邮件地址:-(
Option Explicit
Private Function GetMeetingOrganizer( _
                ByVal appt As Outlook.AppointmentItem) As Outlook.AddressEntry

    If appt Is Nothing Then Exit Function

    Dim PR_SENT_REPRESENTING_ENTRYID As String
        PR_SENT_REPRESENTING_ENTRYID = _
                    "http://schemas.microsoft.com/mapi/proptag/0x00410102"

    Dim organizerEntryID As String
        organizerEntryID = _
                   appt.PropertyAccessor.BinaryToString( _
                   appt.PropertyAccessor.GetProperty(PR_SENT_REPRESENTING_ENTRYID))

    Dim organizer As Outlook.AddressEntry
    Set organizer = Application.Session.GetAddressEntryFromID(organizerEntryID)

    If organizer Is Nothing Then
        Debug.Print "No organizer" ' Print on Immediate Window
    Else
        Debug.Print organizer ' Print on Immediate Window
        Dim Email_Address As String
        If organizer.Type = "SMTP" Then
            Email_Address = organizer.Address
        Else
            If organizer.Type = "EX" Then
                Email_Address = organizer.GetExchangeUser.PrimarySmtpAddress
            End If
        End If

        Debug.Print Email_Address ' Print on Immediate Window

    End If
End Function


Private Sub Example()
    Dim Item As Object

    Set Item = ActiveExplorer.Selection.Item(1)

    Debug.Print TypeName(Item)
    GetMeetingOrganizer Item

End Sub
Function GetOrganizerEmail(ApptItem As Outlook.AppointmentItem) As String
Dim organizer As Outlook.AddressEntry
Set org = ApptItem.GetOrganizer
If org.Type = "SMTP" Then
    GetOrganizerEmail = org.Address
ElseIf org.Type = "EX" Then
    GetOrganizerEmail = org.GetExchangeUser.PrimarySmtpAddress
End If
End Function