'How can I get the account associated to a meeting request?
I need to know the account email address a meeting request is associated to (the email address the meeting request is sent to):
string GetAssociatedAccountEmailAddress(Outlook.MeetingItem meetingItem)
{
//TODO: implement this method:
throw new NotImplementedException();
}
This is what I tried:
string GetAssociatedAccountEmailAddress1(Outlook.MeetingItem meetingItem)
{
Outlook.MAPIFolder folder = meetingItem.Parent;
Debug.WriteLine("Folder Name: {0}, Folder Path: {1}", folder.Name, folder.FolderPath);
Outlook.MAPIFolder folderParent = folder.Parent;
Debug.WriteLine("Folder Parent Name: {0}, Folder Parent Path: {1}", folderParent.Name, folderParent.FolderPath);
return folderParent.FolderPath.Replace("\\", "");
}
Debug output:
Folder Name: Inbox, Folder Path: \\\\[email protected]\Inbox
Folder Parent Name: [email protected], Folder Parent Path: \\\\[email protected]
The problem with this implementation is that I'm not sure the folder path will always contain the email address.
I also tried the following:
string GetAssociatedAccountEmailAddress2(Outlook.MeetingItem meetingItem)
{
Outlook.MAPIFolder folder = meetingItem.Parent;
Outlook.MAPIFolder folderParent = folder.Parent;
Outlook.NameSpace ns = folderParent.Parent;
return ns.Accounts.Cast<Outlook.Account>()
.FirstOrDefault(x => meetingItem.Recipients.Cast<Outlook.Recipient>().Any(r => r.Address == x.SmtpAddress))
.SmtpAddress;
}
The problem with this is that if I have two accounts ([email protected] and [email protected]) and the meeting request is sent to both, then I have two meeting requests but GetAssociatedAccountEmailAddress2
returns the same email address.
FYI: I'm developing an Outlook add-in for Outlook 2013 using VS 2015.
Solution 1:[1]
Couple ways to do that -
Read the
PR_RECEIVED_BY_ENTRYID
property (not guaranteed to be present, DASL namehttp://schemas.microsoft.com/mapi/proptag/0x003F0102
) usingMeetingItem.PropertyAccessor.GetProperty
, convert it to a hex string usingPropertyAccessor.BinaryToString
, use it to callApplication.Session.GetAddressEntryFromID
. Note that the property might not match the actual store owner if the item was copied from another store. Take a look at the meeting request with OutlookSpy (I am its authot) - click IMessage button to see that property.Read the
PR_MAILBOX_OWNER_ENTRYID
property (DASL namehttp://schemas.microsoft.com/mapi/proptag/0x661B0102
) from the parent store (MeetingItem.Parent.Store
) usingStore.PropertyAccessor.GetProperty
. The property is not guaranteed to be present. If using Redemption (I am also its author) is an option, it exposes the RDOExchangeMailboxStore object that has theOwner
property (returns RDOAddressEntry object).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |