Compartilhar via


LastModificationTime Property

Returns a Date specifying the date and time that the Microsoft Outlook item was last modified. This property corresponds to the MAPI property PR_LAST_MODIFICATION_TIME. Read-only.

expression**.LastModificationTime**

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Example

This Visual Basic for Applications example uses the Restrict method to apply a filter to contact items based on the item's LastModificationTime property.

Public Sub ContactDateCheck()
    Dim myOlApp As Outlook.Application
    Dim myNamespace As Outlook.NameSpace
    Dim myContacts As Outlook.Items
    Dim myItems As Outlook.Items
    Dim myItem As Object
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items
    Set myItems = myContacts.Restrict("[LastModificationTime] > '01/1/2003'")
    For Each myItem In myItems
        If (myItem.Class = olContact) Then
            MsgBox myItem.FullName & ": " & myItem.LastModificationTime
        End If
    Next
End Sub

The following Visual Basic for Applications example is the same as the example above, except that it demonstrates the use of a variable in the filter.

Public Sub ContactDateCheck2()
    Dim myOlApp As Outlook.Application
    Dim myNamespace As Outlook.NameSpace
    Dim myContacts As Outlook.Items
    Dim myItem As Outlook.Object
    Dim DateStart As Date
    Dim DateToCheck As String
    Dim myRestrictItems As Outlook.Items
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    Set myContacts = myNameSpace.GetDefaultFolder(olFolderContacts).Items
    DateStart = #01/1/2003#
    DateToCheck = "[LastModificationTime] >= """ & DateStart & """"
    Set myRestrictItems = myContacts.Restrict(DateToCheck)
    For Each myItem In myRestrictItems
         If (myItem.Class = olContact) Then
            MsgBox myItem.FullName & ": " & myItem.LastModificationTime
        End If
    Next
End Sub

Applies to | AppointmentItem Object | ContactItem Object | DistListItem Object | DocumentItem Object | JournalItem Object | MailItem Object | MeetingItem Object | NoteItem Object | PostItem Object | RemoteItem Object | ReportItem Object | TaskItem Object | TaskRequestAcceptItem Object | TaskRequestDeclineItem Object | TaskRequestItem Object | TaskRequestUpdateItem Object