locked
need search folder view to show user defined properties. RRS feed

  • Question

  • Hi,

    I created a search folder to show filter based data from a folder in same pst which is having the application created mail items. Those mail items are having no. of user defined properties to maintain the data and folders are showing them by changing the folder view. When i try to add those user defined propertise in search folder then start getting the below issue. I am using folder.UserDefinedProperties.Add to add the user defined property in search folder and its working on other folders.

    "You don't have appropriate permission to perform this operation"

    I try the same by outlook manually and it shows the same message while creating user property but still adding them in folder.

    I checked with MFCMAPI and find there is a property "PR_ACCESS" which is having value 7 for search folder and other folder this value is 63. I tried to change it but its not changing by MFCMAPI itself.

    I am using vsto 3 with VS2008. Please help me so i can able to add the user defined property in serach folder so can apply the customized view on that otherwise it says that Field does not exists in this folder.


    Anand
    • Edited by Sue Mosher Thursday, July 8, 2010 2:34 PM shortened subject to make it more helpful in search results
    Monday, June 28, 2010 1:53 PM

Answers

  • In my case i am having a folder which is having mailitems with user properties and these are also added in folder as we can see by looking into the folders user defined property collection. No item is hidden or property is hidden.

    I think you're missing an important point of Outlook architecture: If you have defined custom properties in the folder, those property definitions are stored in a hidden item. Each custom view defined for a folder likewise is stored in a hidden item. You can see these items with tools like Outlook Spy and MFCMAPI.exe.

    Search folders, however, do not support storing such hidden items, because they are virtual folders. This is why you cannot create a view specific to a search folder and you cannot create custom property definition in a search folder. There's simply no place in a search folder to store the data pertaining to custom properties and views.

    Now i am making a search folder out of this folder based on some criteria and want to apply the same view which applied on the actual folder but it is not having any user defined property.

    So the only folder included in the search folder is the one where the custom properties are defined, right? This worked for me, creating the views manually: 

    1. Create a new custom property on a folder and populate a few items with data for that property.
    2. Create a new view on the folder -- the "real" folder, not the search folder -- with the scope "on this folder visible to everyone."
    3. Include the custom property in the view. 
    4. Make a copy of that new view with scope "on all Mail and Post folders." 
    5. Create a search folder that returns a filtered set of items in the original folder. 
    When I applied the view in step #3 to the search folder, I was able to see the data from the custom property just fine. 

    It should be possible to do all the steps above programmatically. 

    Tuesday, July 6, 2010 2:01 PM

All replies

  • I don't believe you can do what you want to do. Search folders are special folders and not like other folders.
     
    In a search folder you only have MAPI_ACCESS_DELETE, MAPI_ACCESS_MODIFY and MAPI_ACCESS_READ permissions (0x07) even in your own mailbox or PST file. You don't have permissions for MAPI_ACCESS_CREATE_CONTENTS, which is what you need for adding user properties.
     
    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "Anand Kumar Srivastava" <=?utf-8?B?QW5hbmQgS3VtYXIgU3JpdmFzdGF2YQ==?=> wrote in message news:570feb56-b010-4506-bd2f-967ef0eb386e...

    Hi,

    I created a search folder to show filter based data from a folder in same pst which is having the application created mail items. Those mail items are having no. of user defined properties to maintain the data and folders are showing them by changing the folder view. When i try to add those user defined propertise in search folder then start getting the below issue. I am using folder.UserDefinedProperties.Add to add the user defined property in search folder and its working on other folders.

    "You don't have appropriate permission to perform this operation"

    I try the same by outlook manually and it shows the same message while creating user property but still adding them in folder.

    I checked with MFCMAPI and find there is a property "PR_ACCESS" which is having value 7 for search folder and other folder this value is 63. I tried to change it but its not changing by MFCMAPI itself.

    I am using vsto 3 with VS2008. Please help me so i can able to add the user defined property in serach folder so can apply the customized view on that otherwise it says that Field does not exists in this folder.


    Anand

    Ken Slovak MVP - Outlook
    Monday, June 28, 2010 2:21 PM
  • Hi Ken,

    Thanks for your response.

    In normal scenario its not possible but there could be some other way like by using redeemption by which we can achieve that. While adding the user proeprty manually it shows the message but still adding property in folder, so is there any way by programatically we can add the user defined property in search folder and overlook the error message.


    Anand
    Tuesday, June 29, 2010 6:03 AM
  • Unfortunately I don't know of another way, even with RDO or Extended MAPI (not supported for use in managed code) the permissions would still be the permissions.
     
    Server side code might be more successful. You could use something like EWS possibly. You can check that out. But the permissions might be the problem even with that. I own everything on my server and am the admin of everything and I still can't add properties to a search folder using the UI.
     
    It also would depend on Outlook version as to whether or not you can even add the properties to the folder using the UI. In Outlook 2003 and 2007 the New button in the Field Chooser is disabled for letting you add a new folder property.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "Anand Kumar Srivastava" <=?utf-8?B?QW5hbmQgS3VtYXIgU3JpdmFzdGF2YQ==?=> wrote in message news:0b106e2b-deaf-4512-a21c-c8078b9028f7...

    Hi Ken,

    Thanks for your response.

    In normal scenario its not possible but there could be some other way like by using redeemption by which we can achieve that. While adding the user proeprty manually it shows the message but still adding property in folder, so is there any way by programatically we can add the user defined property in search folder and overlook the error message.


    Anand

    Ken Slovak MVP - Outlook
    • Marked as answer by Mary Lee - MSFT Wednesday, June 30, 2010 9:52 PM
    • Unmarked as answer by Sue Mosher Thursday, July 8, 2010 2:34 PM
    Tuesday, June 29, 2010 1:17 PM
  • Hi Ken,

    In one of your blog you mentioned that if the user property are already there in folder to which we are creating the search folder then will come automatically in search folder, but in my case it is not happening. If i get the user property automatically then i will need not to add them in search folder.

    http://www.dotnetmonster.com/Uwe/Forum.aspx/vs-net-office/1910/Using-search-folders-with-user-property

    The user property are already created when item are inserted in that folder by setting the flag to addtofolder and i also check that its already there in the folder. But when creating a search folder for that folder and showing some mails from there, the newly created search folder is not having those user property.


    Anand
    Tuesday, July 6, 2010 11:45 AM
  • The user property are already created when item are inserted in that folder by setting the flag to addtofolder and i also check that its already there in the folder. But when creating a search folder for that folder and showing some mails from there, the newly created search folder is not having those user property.

    This is because search folders are "virtual" folders, defined solely by their search queries. They do not have the same capability to hold hidden messages as normal folders. And it is in a hidden message that the custom property definitions for a folder are held. 
    Tuesday, July 6, 2010 12:34 PM
  • That thread (not a blog article) is about using a user property for searching items shown in a search folder. It has nothing to do with setting a view using a user property on a search folder. If items have user properties on them you can search for them that way, even in a search folder because the items in a search folder actually live in real folders, not that virtual folder.
     
    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "Anand Kumar Srivastava" <=?utf-8?B?QW5hbmQgS3VtYXIgU3JpdmFzdGF2YQ==?=> wrote in message news:ca29e96c-090e-49f0-9cd5-81a439b46255...

    Hi Ken,

    In one of your blog you mentioned that if the user property are already there in folder to which we are creating the search folder then will come automatically in search folder, but in my case it is not happening. If i get the user property automatically then i will need not to add them in search folder.

    http://www.dotnetmonster.com/Uwe/Forum.aspx/vs-net-office/1910/Using-search-folders-with-user-property

    The user property are already created when item are inserted in that folder by setting the flag to addtofolder and i also check that its already there in the folder. But when creating a search folder for that folder and showing some mails from there, the newly created search folder is not having those user property.


    Anand

    Ken Slovak MVP - Outlook
    Tuesday, July 6, 2010 1:26 PM
  • Hi Sue,

    In my case i am having a folder which is having mailitems with user properties and these are also added in folder as we can see by looking into the folders user defined property collection. No item is hidden or property is hidden. Now i am making a search folder out of this folder based on some criteria and want to apply the same view which applied on the actual folder but it is not having any user defined property.

    I tried by creating a outlook form and put some control and publish and under customize view if i am selecting the form it is showing the user properties and allowing to add in view which i can select to add to folder but dont know how to do the same by code.

    If you have any solution for this pls let me know. I am having a search folder which is having same type mail item with fix user properties and want to implement the view on search folder to show the user properties.


    Anand
    Tuesday, July 6, 2010 1:32 PM
  • In my case i am having a folder which is having mailitems with user properties and these are also added in folder as we can see by looking into the folders user defined property collection. No item is hidden or property is hidden.

    I think you're missing an important point of Outlook architecture: If you have defined custom properties in the folder, those property definitions are stored in a hidden item. Each custom view defined for a folder likewise is stored in a hidden item. You can see these items with tools like Outlook Spy and MFCMAPI.exe.

    Search folders, however, do not support storing such hidden items, because they are virtual folders. This is why you cannot create a view specific to a search folder and you cannot create custom property definition in a search folder. There's simply no place in a search folder to store the data pertaining to custom properties and views.

    Now i am making a search folder out of this folder based on some criteria and want to apply the same view which applied on the actual folder but it is not having any user defined property.

    So the only folder included in the search folder is the one where the custom properties are defined, right? This worked for me, creating the views manually: 

    1. Create a new custom property on a folder and populate a few items with data for that property.
    2. Create a new view on the folder -- the "real" folder, not the search folder -- with the scope "on this folder visible to everyone."
    3. Include the custom property in the view. 
    4. Make a copy of that new view with scope "on all Mail and Post folders." 
    5. Create a search folder that returns a filtered set of items in the original folder. 
    When I applied the view in step #3 to the search folder, I was able to see the data from the custom property just fine. 

    It should be possible to do all the steps above programmatically. 

    Tuesday, July 6, 2010 2:01 PM
  • Thanks Sue,

    It really worked. I had created a copy of view as Global and then created the search folder and for view created a copy of global view and it worked. Thanks as i was really stuck in that.


    Anand
    Thursday, July 8, 2010 2:21 PM