none
Is there any BeforeSave event when user update tasks/notes/appointments/contacts in Outlook RRS feed

  • Question

  • I would like to add some custom properties to the item when user change/create Tasks/Events/Contacts/Notes in Outlook.

    I have added the handler to capture the item add/change event in Outlook.
    e.g:
      AddHandler aHandler.ItemAdd, AddressOf ItemCreate
      AddHandler aHandler.ItemChange, AddressOf ItemModify

    However, these events are triggered after the item is created or updated. If I update the item again in the ItemModify, it's very likely to cause endless loop.

    Is it possible to capture the event "BeforeSave" so that I add some custom properties before Outlook save the item?

    Thanks,

    Cowcow

    Thursday, October 23, 2014 9:16 AM

Answers

  • It doesn't matter what event handler is used. Modifying the item in the Write or ItemChange event will cause a new event. As I wrote, you can check out whether properties are already exist and don't modify the item in the ItemChange event handler to prevent the endless loop.
    • Marked as answer by cowcow222 Friday, October 24, 2014 9:56 AM
    Thursday, October 23, 2014 2:09 PM
  • No, Write event occurs before the changes are actually saved, so you can set your properties without calling Save - Outlook will do that for you immediately after the Write event handler is processed. More than that, the Write event has a by ref Cancel parameter that you can set to true to cancel the modifications.

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

    • Marked as answer by cowcow222 Friday, October 24, 2014 9:56 AM
    Thursday, October 23, 2014 2:22 PM

All replies

  • Hello,

    The Outlook object model provides the BeforeAutoSave event which is fired before the item is automatically saved by Outlook.

    However, you can check out whether properties are already exist and don't modify the item in the ItemChange event handler to prevent the endless loop. Does it make sense?

    Thursday, October 23, 2014 9:34 AM
  • There is the Write event exposed on the item level (ItemEvents). This however means that you will need to subscribe to selection change and new inspector events to track all items that can potentially be modified by the user.

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

    Thursday, October 23, 2014 1:51 PM
  • It doesn't matter what event handler is used. Modifying the item in the Write or ItemChange event will cause a new event. As I wrote, you can check out whether properties are already exist and don't modify the item in the ItemChange event handler to prevent the endless loop.
    • Marked as answer by cowcow222 Friday, October 24, 2014 9:56 AM
    Thursday, October 23, 2014 2:09 PM
  • No, Write event occurs before the changes are actually saved, so you can set your properties without calling Save - Outlook will do that for you immediately after the Write event handler is processed. More than that, the Write event has a by ref Cancel parameter that you can set to true to cancel the modifications.

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

    • Marked as answer by cowcow222 Friday, October 24, 2014 9:56 AM
    Thursday, October 23, 2014 2:22 PM
  • I will try the BeforeAutoSave event.

    Thank you.

    Cowcow

    Friday, October 24, 2014 9:56 AM