vbaoutlookmailitem

MailItem first modification time


I would like to capture date and time when an email was FIRST modified after its creation (e.g. a category tag was added to it). Is it possible to add a FirstModificationTime property to MailItem object - similar to the existing LastModificationTime? How to do it? Any help will be appreciated.


Solution

  • You could add a User Property.

    With FieldChooser | User-defined fields, you can manually create the user-defined field FirstModificationTime or once you run this you can add the automatically created field to the folder view.

    Sub UserProp_FirstModificationTime()
    
        Dim myItem As mailitem
        Dim myUserProperty As UserProperty
    
        Set myItem = ActiveExplorer.Selection.Item(1)
        Set myUserProperty = myItem.UserProperties.Add("FirstModificationTime", olText)
    
        ' If you use a trigger event for this it will update once only.
        If myUserProperty.Value = "" Then
            myUserProperty.Value = Now
            myItem.SAVE
        End If
    
    End Sub