Outlook Mapi access shared contacts

∥☆過路亽.° 提交于 2019-12-04 03:14:03

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

Tobias

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!

I have done some programming to get contact from outlook. I am giving you some example code to help you up with this ..It is not excatly want you want but i think this will help you with your problem...

  using System.Collections.Generic; 

// ... 

private List<Outlook.ContactItem> GetListOfContacts(Outlook._Application OutlookApp) 

    { 
    List<Outlook.ContactItem> contItemLst = null; 
    Outlook.Items folderItems =null; 
    Outlook.MAPIFolder mapiFoldSuggestedConts = null; 
    Outlook.NameSpace nameSpc = null; 
    Outlook.MAPIFolder mapiFoldrConts = null; 
    object itemObj = null; 

    try 
    { 

        contItemLst = new List<Outlook.ContactItem>(); 
        nameSpc = OutlookApp.GetNamespace("MAPI"); 
        // getting items from the Contacts folder in Outlook 
        mapiFoldrConts = 
             nameSpc.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); 

        folderItems = mapiFoldrConts.Items; 
        for (int i = 1; folderItems.Count >= i; i++) 
        { 

            itemObj = folderItems[i]; 
            if (itemObj is Outlook.ContactItem) 
                contItemLst.Add(itemObj as Outlook.ContactItem); 
            else 
                Marshal.ReleaseComObject(itemObj); 
        } 

        Marshal.ReleaseComObject(folderItems); 
        folderItems = null; 
        // getting items from the Suggested Contacts folder in Outlook 
        mapiFoldSuggestedConts = nameSpc.GetDefaultFolder( 

             Outlook.OlDefaultFolders.olFolderSuggestedContacts); 

        folderItems = mapiFoldSuggestedConts.Items; 

        for (int i = 1; folderItems.Count >= i; i++) 
        { 

            itemObj = folderItems[i]; 
            if (itemObj is Outlook.ContactItem) 
                contItemLst.Add(itemObj as Outlook.ContactItem); 

            else 
                Marshal.ReleaseComObject(itemObj); 
        } 
    } 

    catch (Exception ex) 
    { 
        System.Windows.Forms.MessageBox.Show(ex.Message); 
    } 

    finally 
    { 

        if (folderItems != null) 
            Marshal.ReleaseComObject(folderItems); 
        if (mapiFoldrConts != null) 
            Marshal.ReleaseComObject(mapiFoldrConts); 
        if (mapiFoldSuggestedConts != null) 
            Marshal.ReleaseComObject(mapiFoldSuggestedConts); 
        if (nameSpc != null) Marshal.ReleaseComObject(nameSpc); 
    } 

    return contItemLst; 

} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!