如何获得预约组织者的电子邮件地址

时间:2019-09-26 13:22:16

标签: vba outlook outlook-vba organizer

我正在尝试自动发送电子邮件并通过Outlook VBA宏复制会议组织者。

我的公司正在使用Office365。

我找到了item。GetOrganizer元素来获取组织者的名称,但是找不到一种方法来获取组织者的电子邮件地址。

这可用吗?如果是这样,我在哪里可以找到它?谢谢。

2 个答案:

答案 0 :(得分:0)

示例

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

答案 1 :(得分:0)

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