Get Smtp email from ContactInfo stored in Exchange

前端 未结 1 629
故里飘歌
故里飘歌 2021-01-15 00:05

I am using VSTO for my Outlook add-in. Currently I am processing email addresses from all Outlook contacts. There is no problem for instances of ContactInfo if EmailAddress1

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 00:15

    Here is the MSDN reference link and corresponding sample code:

    private const string Email1EntryIdPropertyAccessor = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80850102";
    
    PropertyAccessor propertyAccessor = contactItem.PropertyAccessor;
    object rawPropertyValue = propertyAccessor.GetProperty(Email1EntryIdPropertyAccessor);
    string recipientEntryID = propertyAccessor.BinaryToString(rawPropertyValue);
    Recipient recipient = contactItem.Application.Session.GetRecipientFromID(recipientEntryID);
    if (null == recipient)
        throw new InvalidOperationException();
    
    bool wasResolved = recipient.Resolve();
    if (!wasResolved)
        throw new InvalidOperationException();
    ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
    string smtpAddress = exchangeUser.PrimarySmtpAddress;
    

    0 讨论(0)
提交回复
热议问题