问题
I'm developing an Outlook Add-In to send all the appointments to a web app and I'm having some trouble consistently getting the "owner" (not the organizer) of an AppointmentItem.
For example, X sends an appointment to Y and Z. The Add-In will get three appointment items out of it, I'm trying to get the email address of X, Y and Z.
I tried to look into the SendUsingAccount (sometimes set to null) or the Parent property but I can't seem to find what I'm looking for.
Thanks for your help!
回答1:
If it is the default account and assuming there is only one primary Exchange account configured in Outlook, you can simply use Application.Session.CurrentUser
.
UPDATE:
If you are accessing an appointment from a non-default Exchange account, you can retrieve the parent Store
- you can do that through AppointmentItem.Parent
(it will be MAPIFolder
), then use MAPIFolder.Store
or StoreID
property. You can then match the store to an Account
object from the Namespace.Accounts
collection using Account.DeliveryStore
. Compare the two store entry ids using Namespace.CompareEntryIDs
, don't compare the strings directly.
Once you can the Account object, you can use Account.CurrentUser property.
If using Redemption is an option (I am its author), it exposes RDOExchangeMailboxStore.Owner
property so that you don't have to go through the accounts: just create RDOSession object, set its MAPIOBJECT
property to Application.Session.MAPIOBJECT
from Outlook, reopen the appointment appointment using RDOSession.GetMessageFromID
or GetRDOObjectFromOutlookObject
, and use RDOAppointmentItem.Parent.Store.Owner
.
来源:https://stackoverflow.com/questions/57631333/getting-calendars-owner-email-address-of-an-appointmentitem