none
How add a click option to UserProperties field. RRS feed

  • Question

  • hi, i'm using this to add a new field to my inbox view, but i want to add a Onclick option to this fields, to can change from true to false by mouse click.

    any idea?

    Outlook.MailItem mailItem = (this.Application.ActiveExplorer().Selection[item] as Outlook.MailItem);
    mailItem.UserProperties.Add("New", Outlook.OlUserPropertyType.olYesNo, AddToFolderFields: true, DisplayFormat: 1);
    mailItem.UserProperties["New"].Value = true;
    mailItem.Save();

    thanks.

    Thursday, May 10, 2012 8:00 AM

Answers

  • The types of columns that are supported for use in views don't include buttons.
     
    Something like a ribbon button could get ActiveExplorer().Selection[1] and change the state of a property on that item when it was clicked, but the button wouldn't be in a row or column.
     
    A Boolean property (yes/no, true/false) can be shown in a view as a checkbox, I've done that many times. What you can do would be to use the customize view dialog in the user interface to create a view that shows your user property as a checkbox and then you can read the Explorer.View properties to see what the code for that view looks like.

    --
    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
     
     
    "AkiKnight" <=?utf-8?B?QWtpS25pZ2h0?=> wrote in message news:b64fa804-cd93-49c5-8d1b-43a6635769ab...

    Thanks a lot Ken, that type of column i make it, but only i can change the state by code and i need to do it when i click on that column-item, 

    in this moment i mark some mails with menu option, then when i press send&receive i put that mails in other system. but i need to mark the mail by clicking on it. like when you click the category, everu time you click the category change from nothing to red.

    The flag is other example of i need.. if you click on mark of follow the red flag come on.

    i dont know why if exist that type of fields we can't make it.

    if i can use the checkbox and they change when i click, that can i use.

    thanks a lot again.

    Aki.


    Ken Slovak MVP - Outlook
    Friday, May 11, 2012 5:35 PM

All replies

  • User properties cannot directly do what you want.
     
    You need to customize the ribbon with your VSTO addin to add a button that does what you want, or you need to customize the Outlook form used to display the item with that user property in it to have a button, or create a form region with a button. 

    --
    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
     
     
    "AkiKnight" <=?utf-8?B?QWtpS25pZ2h0?=> wrote in message news:09f80ea3-24b8-4e46-9951-fa4964697e34...

    hi, i'm using this to add a new field to my inbox view, but i want to add a Onclick option to this fields, to can change from true to false by mouse click.

    any idea?

    Outlook.MailItem mailItem = (this.Application.ActiveExplorer().Selection[item] as Outlook.MailItem);
    mailItem.UserProperties.Add("New", Outlook.OlUserPropertyType.olYesNo, AddToFolderFields: true, DisplayFormat: 1);
    mailItem.UserProperties["New"].Value = true;
    mailItem.Save();

    thanks.


    Ken Slovak MVP - Outlook
    Thursday, May 10, 2012 1:53 PM
  • :( thanks for answer, do you have a sample to add a button to a new column and how to add the click event to that button?

    or where i can search about it.

    thanks a lot.

    Friday, May 11, 2012 8:52 AM
  • i think you misunderstood Ken's answer a little bit - you can add button to outlook's Ribbon - which is new menu on top of outlook. You cannot modify folder view in such way that you can add buttons there or detect that your particular cell in proper column was clicked. As Ken said - you can either select element in inbox view and then click button in ribbon (menu item) or you can right click mail in mailbox view and choose option from context menu.
    Friday, May 11, 2012 10:55 AM
  • puff, that i know how to do it.. what i need is add a eventhandller to my new field on inbox folder.., in this moment i'm using a menu option to change the value on this personal field. but i need to do it with mouse click.

    remember i can change the state with 

    mailItem.UserProperties["New"].Value = true;
    mailItem.Save();

    but i dont know how to do it with mouse click.. like flag field or category field there we click on it and change color o put the flag.

    thanks.

    Friday, May 11, 2012 11:10 AM
  • i do not think it is possible, but let's wait for Ken to answer this.
    Friday, May 11, 2012 11:41 AM
  • It's not possible to add a  button to the folder view.
     
    For a user property added to the folder you can add a yes/no field to the view and it will appear as a checkbox column in the each row, if that will work. A custom view can be deployed if you have a COM addin and add the custom view as part of your initialization code.
     
    If that won't work the options depend on whether or not you want to deploy the solution. If you do want to deploy it then you need a COM addin to deploy your ribbon customization.
     
    I'd recommend going to www.outlookcode.com and checking out the information there on COM addins, the ribbon and ribbon customization, and on customizing views.

    --
    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
     
     
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:7d7dc497-6719-48c3-aaac-8f03a724860f...
    i do not think it is possible, but let's wait for Ken to answer this.

    Ken Slovak MVP - Outlook
    Friday, May 11, 2012 2:05 PM
  • Thanks a lot Ken, that type of column i make it, but only i can change the state by code and i need to do it when i click on that column-item, 

    in this moment i mark some mails with menu option, then when i press send&receive i put that mails in other system. but i need to mark the mail by clicking on it. like when you click the category, everu time you click the category change from nothing to red.

    The flag is other example of i need.. if you click on mark of follow the red flag come on.

    i dont know why if exist that type of fields we can't make it.

    if i can use the checkbox and they change when i click, that can i use.

    thanks a lot again.

    Aki.

    Friday, May 11, 2012 3:43 PM
  • The types of columns that are supported for use in views don't include buttons.
     
    Something like a ribbon button could get ActiveExplorer().Selection[1] and change the state of a property on that item when it was clicked, but the button wouldn't be in a row or column.
     
    A Boolean property (yes/no, true/false) can be shown in a view as a checkbox, I've done that many times. What you can do would be to use the customize view dialog in the user interface to create a view that shows your user property as a checkbox and then you can read the Explorer.View properties to see what the code for that view looks like.

    --
    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
     
     
    "AkiKnight" <=?utf-8?B?QWtpS25pZ2h0?=> wrote in message news:b64fa804-cd93-49c5-8d1b-43a6635769ab...

    Thanks a lot Ken, that type of column i make it, but only i can change the state by code and i need to do it when i click on that column-item, 

    in this moment i mark some mails with menu option, then when i press send&receive i put that mails in other system. but i need to mark the mail by clicking on it. like when you click the category, everu time you click the category change from nothing to red.

    The flag is other example of i need.. if you click on mark of follow the red flag come on.

    i dont know why if exist that type of fields we can't make it.

    if i can use the checkbox and they change when i click, that can i use.

    thanks a lot again.

    Aki.


    Ken Slovak MVP - Outlook
    Friday, May 11, 2012 5:35 PM