Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook Mapi access shared contacts

I want to import contacts from Outllok via Mapi. First step with standard contact is no problem:

MAPIFolder contactObjects = 
outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
foreach (ContactItem contactObject in contactObjects.Items) {
    ... import contact ...
}

In a second step I additionally want to import shared contacts. Only thing I found was using

OpenSharedItem(sharedContacts.vcf)

but I don't know the name of the file (shared item) I want to open. Does someone know how to access shared contacts and can help me out?

Tobi


Update:

Thanks for the hint with the vcf-Files. But where do I find them?


Update2:

I played around with OutlookSpy. I got access to the folder with shared contacts, but only by knowing the id (which is of course different for other users):

var ns = outlookObj.GetNamespace("MAPI");
var flr = ns.GetFolderFromID("00000000176A90DED92CE6439C1CB89AFE3668F90100D1AD8F66B576B54FB731302D9BB9F6C40007E4BAC5020000");

foreach (var contactObject in flr.Items) {
       ...
}

How do I get access to the folder without knowing the id?

like image 938
Tobias Avatar asked Nov 02 '12 10:11

Tobias


People also ask

How do I access shared mailbox Contacts?

If you have permissions to a shared mailbox, the contacts folder from the shared mailbox is automatically added to your My Contact list. In Outlook, select People. Under My Contacts, select the contacts folder for the shared contacts list.

Does Outlook still use MAPI?

Choosing an email protocolUsers with Microsoft Outlook and an Exchange server will almost always use MAPI.

What is a MAPI Outlook address book?

The MAPI address book is similar in structure to a message store in that it is organized hierarchically. The address book provides access to three types of objects implemented by an address book provider: An address book container object. A distribution list object. A messaging user object.


2 Answers

You will need to either explicitly parse the vCard files or you can use Redemption (I am its author) - it allows to import vCard files using RDOContactItem.Import - http://www.dimastr.com/redemption/RDOMail.htm#methods

like image 106
Dmitry Streblechenko Avatar answered Oct 08 '22 19:10

Dmitry Streblechenko


Well the solution to the question as it is asked in the title is almost simple. You just need to call:

Recipient recip = Application.Session.CreateRecipient("Firstname Lastname");
MAPIFolder sharedContactFolder = Application.Session.GetSharedDefaultFolder(recip, OlDefaultFolders.olFolderContacts);

Because this does not solve my problem I will ask another question!

like image 36
Tobias Avatar answered Oct 08 '22 18:10

Tobias