VSTO Outlook.Recipients值显示外部电子邮件地址的方式与内部电子邮件地址的方式不同

时间:2019-01-18 01:00:45

标签: vb.net vsto outlook-addin

我们有一个Outlook VSTO加载项,它正在检查Outlook.Recipients域以查看收件人是否在我们网络的外部

Dim objRecipients As Outlook.Recipients

所以说有两个我们要遍历并检查域的收件人:

Do While objRecipients.Count >= loopCount
  If InStr(1, objRecipients(loopCount).Address, "@") Then
    ...
  End If
  Loop +=1
Loop

对于外部objRecipient(loopCount)。我们看到的地址说:

  gmail.com

哪个好。

但是,对于内部地址,我们似乎看到的是LDAP / Exchange地址而不是SMTP地址,如下所示:

/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=9asd9asd9d9d9asd9asd9asd9asd9asd9asd-Fred Smith"

这似乎刚刚开始发生,但不确定为什么或如何解决此问题。

为什么会这样?

谢谢

1 个答案:

答案 0 :(得分:0)

以下文章有助于我们解决问题:

https://docs.microsoft.com/en-us/office/vba/outlook/Concepts/Address-Book/obtain-the-e-mail-address-of-a-recipient

我们需要使用Outlook.PropertyAccessor属性来获取正确的SMTP地址:

  Dim objRecipients As Outlook.Recipients

  Dim pa As Outlook.PropertyAccessor
  Const PR_SMTP_ADDRESS As String = 
  "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"

        Do While objRecipients.Count >= loopCount

            'set propertyaccessor object
            pa = objRecipients(loopCount).PropertyAccessor

           'set propertyaccessor domain based on smtp address
           paDomain = pa.GetProperty(PR_SMTP_ADDRESS)

           Loop +=1
 Loop