views:

86

answers:

1

I'd like to retrieve a contact with a known EntryID in a specific folder from outlook/exchange using Redemption.

The following code calls GetMessageFromID on an RDOSession object. I only want contacts from the standard Contacts folder, so I use the second argument to limit the search space.

RDOFolder folder = Session.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);
RDOContactItem i = Session.GetMessageFromID(syncRow.SyncId, folder.EntryID, null) as RDOContactItem;

Whenever I do this redemption throws a COM exception: Error in IMAPISession.OpenMsgStore: MAPI_E_INVALID_ENTRYID. What am I doing wrong?

+1  A: 

GetMessageFromID takes 2 entry ids as parameters (1 required, 1 optional) - the message entry id and the store entry id. It looks like you are passing a folder entry id instead of a store entry id.

Dmitry Streblechenko
Ah... Is there a way to limit it to folders in a store? Currently I'm just checking where the RDOContactItem lives after I've got it.
Matt Jacobsen
You can use RDOContactItem.Parent to retrieve the parent folder(RDOFolder). You can then use RDOSession.CompareEntryIDs to compare the folder entry id with the entry id of another folder.
Dmitry Streblechenko
Thanks for the tip. I was comparing them with ==. Fixed that now.
Matt Jacobsen