none
How to capture MailItem property change from Unread to Read in outlook 2010 Addins. RRS feed

  • Question

  • Hi All,

    I am developing an Addin for Outlook 2010, where I need to fire an event when the mail property change from UnRead to Read.

    I tried MailItem.PropertyChange event but no success, please guide me.

    Thanks in Advance


    Dharmender Sharma

    Thursday, March 7, 2013 7:37 AM

Answers

  • Items.ItemChange event will fire on the items' parent folder.

    PropertyChange event will also fire. Please show how you set up the event sink. 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, March 7, 2013 4:51 PM
  • If you implement the event it will fire for all items that change anything in the folder. Set up your code to just exit the event handler if your conditions are not met.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "dharma12" <=?utf-8?B?ZGhhcm1hMTI=?=> wrote in message news:e90afef7-7539-48bd-81a0-7dd6d7367737...

    Hi Dmitry,


    Thanks for reply, it really help me to get the mail item which is being changed.


    below are the code I written
     - On startup
    Outlook.Items outlookItems = Application.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox).Items;

    outlookItems.ItemChange += new ItemsEvents_ItemChangeEventHandler(outlookItems_ItemChange);

    Function
     
    void outlookItems_ItemChange(object Item){

    if (Item is MailItem){
    MailItem mailItem = Item as MailItem;
    MessageBox.Show("Item Change " + mailItem.Subject);}

    }

    But now I am facing on proble by implementing this, Now this function is fired even if new mail is coming into outlook.
    I only want to fire this event or function only when mail status is changed from Unread to read.

    Thanks in Advance


    Dharmender Sharma


    Ken Slovak MVP - Outlook
    Friday, March 8, 2013 3:25 PM
    Moderator

All replies

  • Items.ItemChange event will fire on the items' parent folder.

    PropertyChange event will also fire. Please show how you set up the event sink. 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, March 7, 2013 4:51 PM
  • Hi Dmitry,


    Thanks for reply, it really help me to get the mail item which is being changed.


    below are the code I written
     - On startup
    Outlook.Items outlookItems = Application.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox).Items;

    outlookItems.ItemChange += new ItemsEvents_ItemChangeEventHandler(outlookItems_ItemChange);

    Function
     
    void outlookItems_ItemChange(object Item){

    if (Item is MailItem){
    MailItem mailItem = Item as MailItem;
    MessageBox.Show("Item Change " + mailItem.Subject);}

    }

    But now I am facing on proble by implementing this, Now this function is fired even if new mail is coming into outlook.
    I only want to fire this event or function only when mail status is changed from Unread to read.

    Thanks in Advance


    Dharmender Sharma

    Friday, March 8, 2013 5:46 AM
  • If you implement the event it will fire for all items that change anything in the folder. Set up your code to just exit the event handler if your conditions are not met.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "dharma12" <=?utf-8?B?ZGhhcm1hMTI=?=> wrote in message news:e90afef7-7539-48bd-81a0-7dd6d7367737...

    Hi Dmitry,


    Thanks for reply, it really help me to get the mail item which is being changed.


    below are the code I written
     - On startup
    Outlook.Items outlookItems = Application.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox).Items;

    outlookItems.ItemChange += new ItemsEvents_ItemChangeEventHandler(outlookItems_ItemChange);

    Function
     
    void outlookItems_ItemChange(object Item){

    if (Item is MailItem){
    MailItem mailItem = Item as MailItem;
    MessageBox.Show("Item Change " + mailItem.Subject);}

    }

    But now I am facing on proble by implementing this, Now this function is fired even if new mail is coming into outlook.
    I only want to fire this event or function only when mail status is changed from Unread to read.

    Thanks in Advance


    Dharmender Sharma


    Ken Slovak MVP - Outlook
    Friday, March 8, 2013 3:25 PM
    Moderator
  • Please don't hijack existing, closed threads. Start a new thread for your problem.

    That said, you would need to handle the item.PropertyChange() event as was discussed in the thread, not the Items.ItmeChange() event. The item.PropertyChange() event tells you what property changed.

    Are you using cached Exchange mode? Perhaps some cache synching is occurring and changing some property such as a modified date/time at that point.


    Ken Slovak MVP - Outlook

    Monday, July 15, 2013 2:55 PM
    Moderator