none
Get Outlook item's properties before change event RRS feed

  • Question

  • Hi all,

    I have a problem with the event ItemChange(ByVal Item As Object).
    I need the properties of Item before the event Change occurs, but I get only the properties after change (for example Item.Subject, Item.Start, Item.End...)

    Do you have any idea? Tks for your help!
    Tuesday, May 29, 2012 12:09 PM

Answers

  • In NewInspector() you get what's called a weak object reference where all properties of Inspector.CurrentItem have not yet been populated. Attempts to get much more than Class or MessageClass will mostly not work or work consistently. The best place to get those properties would be in the first Activate() event of the Inspector.
     
    To cover the possibility of items being changed when selected in a folder view (in-cell editing) the ActiveExplorer().SelectionChange() event should also be handled and the item that's selected should be handled too.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:66ed1bff-46c4-41c5-ad68-4c6919a4c7bb...
    you have to store them by yourself on newinspector event (or any other event that suits your needs, just remembet that ItemLoad will not be good for your needs).

    Ken Slovak MVP - Outlook
    Tuesday, May 29, 2012 1:27 PM
  • Thank you very much, I have succeeded to use Inspector events to get the properties of an appointment item :

    Dim WithEvents myInspector As Outlook.Inspectors
    Public subject As String
    Public busyStatus As Integer
    Public allDayEvent As Boolean
    Public startTime As Date
    Public endTime As Date
    Public reminderSet As Boolean
    Private Sub Application_startup()
        Set myInspector = Application.Inspectors
    End Sub
    Private Sub myInspector_NewInspector(ByVal Inspector As Outlook.Inspector)
        Dim objAppt As Outlook.AppointmentItem
        If Inspector.CurrentItem.Class = olAppointment Then
            Set objAppt = Inspector.CurrentItem
            subject = objAppt.subject
            busyStatus = objAppt.busyStatus
            allDayEvent = objAppt.allDayEvent
            startTime = objAppt.Start
            endTime = objAppt.End
            reminderSet = objAppt.reminderSet
        End If
        Set objAppt = Nothing
    End Sub

    But this solution have one problem : when we change the date of an appointment by drag-and-drop, we have not an inspector. How can I fix it?

    Wednesday, May 30, 2012 12:49 PM
  • About the only thing that I can think of that would work for that would be to handle the Folder.Items.ItemChange() event.
     
    You'd need to set up to handle that each time the CurrentFolder object in ActiveExplorer() changed, in the Explorer.BeforeFolderSwitch() event
     
    That event would give you a handle to the item being modified, it would be up to you to find out what was modified on the item.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "bboy0303" <=?utf-8?B?YmJveTAzMDM=?=> wrote in message news:efa856fc-806b-41ae-bedb-aa98e077fe7c...

    Thank you very much, I have succeeded to use Inspector events to get the properties of an appointment item :

    Dim WithEvents myInspector As Outlook.Inspectors
    Public subject As String
    Public busyStatus As Integer
    Public allDayEvent As Boolean
    Public startTime As Date
    Public endTime As Date
    Public reminderSet As Boolean
    Private Sub Application_startup()
        Set myInspector = Application.Inspectors
    End Sub
    Private Sub myInspector_NewInspector(ByVal Inspector As Outlook.Inspector)
        Dim objAppt As Outlook.AppointmentItem
        If Inspector.CurrentItem.Class = olAppointment Then
            Set objAppt = Inspector.CurrentItem
            subject = objAppt.subject
            busyStatus = objAppt.busyStatus
            allDayEvent = objAppt.allDayEvent
            startTime = objAppt.Start
            endTime = objAppt.End
            reminderSet = objAppt.reminderSet
        End If
        Set objAppt = Nothing
    End Sub

    But this solution have one problem : when we change the date of an appointment by drag-and-drop, we have not an inspector. How can I fix it?


    Ken Slovak MVP - Outlook
    Wednesday, May 30, 2012 2:10 PM

All replies

  • you have to store them by yourself on newinspector event (or any other event that suits your needs, just remembet that ItemLoad will not be good for your needs).
    Tuesday, May 29, 2012 1:11 PM
  • In NewInspector() you get what's called a weak object reference where all properties of Inspector.CurrentItem have not yet been populated. Attempts to get much more than Class or MessageClass will mostly not work or work consistently. The best place to get those properties would be in the first Activate() event of the Inspector.
     
    To cover the possibility of items being changed when selected in a folder view (in-cell editing) the ActiveExplorer().SelectionChange() event should also be handled and the item that's selected should be handled too.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:66ed1bff-46c4-41c5-ad68-4c6919a4c7bb...
    you have to store them by yourself on newinspector event (or any other event that suits your needs, just remembet that ItemLoad will not be good for your needs).

    Ken Slovak MVP - Outlook
    Tuesday, May 29, 2012 1:27 PM
  • Thank you very much, I have succeeded to use Inspector events to get the properties of an appointment item :

    Dim WithEvents myInspector As Outlook.Inspectors
    Public subject As String
    Public busyStatus As Integer
    Public allDayEvent As Boolean
    Public startTime As Date
    Public endTime As Date
    Public reminderSet As Boolean
    Private Sub Application_startup()
        Set myInspector = Application.Inspectors
    End Sub
    Private Sub myInspector_NewInspector(ByVal Inspector As Outlook.Inspector)
        Dim objAppt As Outlook.AppointmentItem
        If Inspector.CurrentItem.Class = olAppointment Then
            Set objAppt = Inspector.CurrentItem
            subject = objAppt.subject
            busyStatus = objAppt.busyStatus
            allDayEvent = objAppt.allDayEvent
            startTime = objAppt.Start
            endTime = objAppt.End
            reminderSet = objAppt.reminderSet
        End If
        Set objAppt = Nothing
    End Sub

    But this solution have one problem : when we change the date of an appointment by drag-and-drop, we have not an inspector. How can I fix it?

    Wednesday, May 30, 2012 12:49 PM
  • experiment with item's Open/Read/Write etc. events, see if you can use it to handle this situation.
    Wednesday, May 30, 2012 1:18 PM
  • About the only thing that I can think of that would work for that would be to handle the Folder.Items.ItemChange() event.
     
    You'd need to set up to handle that each time the CurrentFolder object in ActiveExplorer() changed, in the Explorer.BeforeFolderSwitch() event
     
    That event would give you a handle to the item being modified, it would be up to you to find out what was modified on the item.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "bboy0303" <=?utf-8?B?YmJveTAzMDM=?=> wrote in message news:efa856fc-806b-41ae-bedb-aa98e077fe7c...

    Thank you very much, I have succeeded to use Inspector events to get the properties of an appointment item :

    Dim WithEvents myInspector As Outlook.Inspectors
    Public subject As String
    Public busyStatus As Integer
    Public allDayEvent As Boolean
    Public startTime As Date
    Public endTime As Date
    Public reminderSet As Boolean
    Private Sub Application_startup()
        Set myInspector = Application.Inspectors
    End Sub
    Private Sub myInspector_NewInspector(ByVal Inspector As Outlook.Inspector)
        Dim objAppt As Outlook.AppointmentItem
        If Inspector.CurrentItem.Class = olAppointment Then
            Set objAppt = Inspector.CurrentItem
            subject = objAppt.subject
            busyStatus = objAppt.busyStatus
            allDayEvent = objAppt.allDayEvent
            startTime = objAppt.Start
            endTime = objAppt.End
            reminderSet = objAppt.reminderSet
        End If
        Set objAppt = Nothing
    End Sub

    But this solution have one problem : when we change the date of an appointment by drag-and-drop, we have not an inspector. How can I fix it?


    Ken Slovak MVP - Outlook
    Wednesday, May 30, 2012 2:10 PM