問題描述
Outlook Addin 中的 Recipient.Name 和 ExchangeUser.Name 有什麼區別? (What is the Difference Between Recipient.Name and ExchangeUser.Name in Outlook Addin?)
ExchangeUser</code> 使用 Recipient.AddressEntry.GetExchangeUser()
。我使用哪個 name
屬性是否重要?兩者之間有什麼區別(除了文檔的寫入/讀取差異)。</p>
參考解法
方法 1:
I am not an expert on Microsoft product line. But just from the naming, Outlook is a client and Exchange is a server.
That is to say, you can use Recipient object to refer to an addressee in your Outlook client, no matter what the actual mail server is, it can be Exchange, as in your case, or it can be Gmail, Yahoo! Mail, mail.live.com, whatever.
And the ExchangeUser object is specifically used for Exchange mailbox user, which is typically set up in enterprise. So you can find detailed properties like JobTitle and OfficeLocation (and a lot more) which the Recipient object doesn’t have.
This object provides first‑class access to properties applicable to Exchange users such as FirstName, JobTitle, LastName, and OfficeLocation.
Note that you cannot use Recipient.AddressEntry.GetExchangeUser() if you are not connected to an Exchange server.
方法 2:
Recipient object is stored inside the message itself as a row in the recipient table. Recipient.Name
corresponds to PR_DISPLAY_NAME
. The PR_ENTRYID
property in that row (present if the recipient is resolved) points to the address book object. That is what Recipient.AddressEntry
returns ‑ it uses recipient's PR_ENTRYID
to call IAddrBook::OpenEntry
.
The returned AddressEntry.Name
can in theory be different from Recipient.Name
(one comes from the address book object and another from PR_DISPLAY_NAME
in the message recipient table). ExchangeUser
is essentially an extension of the AddressEntry
object with Exchange specific properties, so ExchangeUser.Name
should be the same as AddressEntry.Name
.
You can see this using OutlookSpy (I am its author) ‑ select a message, go to the GetRecipientTable tab. Right lick on the PR_ENTRYID
property and select IMAPISession::OpenEntry
. You can also edit PR_DISPLAY_NAME
property to something different from the GAL object. PR_DISPLAY_TO
property on the message will reflect the new recipient name when the message is saved.
(by Thomas、kennyzx、Dmitry Streblechenko)