guatelize
06-16-2011, 02:43 AM
Hello
I'm having trouble to get this macro work to delete from a specific Inbox subfolder "My Folder" after 4 hours from current time containing a specific subject string "RawData" :
Public Sub InboxItemCheck()
Dim myNamespace As Outlook.NameSpace
Dim myAppts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Dim i As Long
Dim DateStart As Date
Dim DateToCheck As String
DateStart = Date
DateToCheck = LastModificationTime >= """ & DateStart & """"
Set myNamespace = Application.GetNamespace("MAPI")
Set myAppts = myNamespace.GetDefaultFolder(olFolderInbox).Items
Set myItems = myAppts.Restrict(DateToCheck)
For i = myItems.Count To 1 Step -1
Set myItem = myItems.Item(i)
If (InStr(myItem.Subject, "RawData")) Then
myItem.Delete
End If
Next
End Sub
Thanks for your help
I'm having trouble to get this macro work to delete from a specific Inbox subfolder "My Folder" after 4 hours from current time containing a specific subject string "RawData" :
Public Sub InboxItemCheck()
Dim myNamespace As Outlook.NameSpace
Dim myAppts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Dim i As Long
Dim DateStart As Date
Dim DateToCheck As String
DateStart = Date
DateToCheck = LastModificationTime >= """ & DateStart & """"
Set myNamespace = Application.GetNamespace("MAPI")
Set myAppts = myNamespace.GetDefaultFolder(olFolderInbox).Items
Set myItems = myAppts.Restrict(DateToCheck)
For i = myItems.Count To 1 Step -1
Set myItem = myItems.Item(i)
If (InStr(myItem.Subject, "RawData")) Then
myItem.Delete
End If
Next
End Sub
Thanks for your help