locked
Accessing Contact Categories(all categories) in Compact Framework RRS feed

  • Question

  •      I have outlook object. I was able to retrieve each item in the contacts. If I want to create new contact from my application, I want to have to ability to select Category for that contact. What is the way to retrieve list of all categories using Compact Framework 2.0 VS2005 WM5.0?

    Thanks,
    Vijay

    Tuesday, January 23, 2007 7:38 PM

Answers

  • Sadly this isn't exposed through the WM5.0 managed APIs. If you are comfortable working with the native POOM interfaces (using COM interop in .NETCF 2.0) you need to get the IItem interface for the Contacts folder. Then retrieve the PIMPR_FOLDER_CATEGORIES property. There is a native code example in the SDK Help file on the Shared Property ID's topic.

    Peter

    Wednesday, January 24, 2007 11:47 AM

All replies

  • Sadly this isn't exposed through the WM5.0 managed APIs. If you are comfortable working with the native POOM interfaces (using COM interop in .NETCF 2.0) you need to get the IItem interface for the Contacts folder. Then retrieve the PIMPR_FOLDER_CATEGORIES property. There is a native code example in the SDK Help file on the Shared Property ID's topic.

    Peter

    Wednesday, January 24, 2007 11:47 AM
  • Hi.

    I've tried to do this, but not successful.

       
     HRESULT           hr = E_FAIL; 
        IFolder    * pFolder = NULL; 
        IItem * pFolderIItem = NULL; 
        CEPROPVAL    * pVals = NULL; 
        int           cProps = 1
     
        CEPROPID rgPropIDs[] = { PIMPR_FOLDER_CATEGORIES }
     
        HANDLE hHeap = GetProcessHeap(); 
     
        // Get the IFolder object (Contacts, Contacts, Tasks). 
        hr = polApp->GetDefaultFolder(olFolderType, &pFolder); 
     
        // Get the IItem object representing a IFolder object. 
        hr = pFolder->QueryInterface(IID_IItem, (LPVOID*)&pFolderIItem); 
     
        // Get the list of categories. 
        hr = pFolderIItem->GetProps(rgPropIDs, CEDB_ALLOWREALLOC, cProps, &pVals, 0, hHeap); 
     
     



    I am able to get the Folder and the IItem interface.
    But not able to get the property PIMPR_FOLDER_CATEGORIES.

    I am able to get the categories, by getting the contact and then the category using Icontact::get_categories.

    What could be the problem?

    I want to get the list of categories, without reading the contact.
    Then I want to read the contacts in that selected category.


    Akash M Thambiran

    Wednesday, March 11, 2009 12:27 PM
  • I'm facing the same problem that Akash is having above. I'm able to get to folder and item interface. However, when I try to fetch the categories, GetProps returns E_INVALIDARG.
    Wednesday, July 1, 2009 11:02 AM
  • Hello All,

    I am also facing exactly the same problem.

    For GetProp it gives INVAILD ARG as return value.

    Kindly suggest somthing.

    Priya
    Thursday, August 20, 2009 5:05 AM
  • Hi all,

    I am able to get the list of categories from the below mentioned code.We were missing few additional steps.
    http://www.eggheadcafe.com/forumarchives/windowsceappdevelopment/Jun2005/post23163237.asp

    But with this I am able to get only those Categories which have contacts linked with them. If any of the category dont have any conatct associated with it, it is not getting listed.

    Can anybody help me on getting list of all the categories?

    Thanks in advance.

    Best Regards,
    Priya

     

    Thursday, August 20, 2009 6:04 AM
  • Thanks Priya for that post.
    Tuesday, February 2, 2010 9:56 AM
  • Thank Priya.

    Can you translate this code as Managed Code?

    Friday, July 16, 2010 7:03 PM