S
Steve Roberts
The code below moves any mail items older than X to a specified folder. It
works fine except when it hits a read reciept or an admistrative bounce back
message. If it hits either of these it throws and error # 424 "Object
required"
Any ideas on how I might be able to move the report items?
Thanks for any suggestions you might have.
Steve
Private Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder, RestrictDate
As Date)
Dim olTempItem As Object
Dim myOlApp As New Outlook.Application
Dim myNS As Outlook.NameSpace
Dim myRestrictItems As Items
Dim fldNew As Outlook.MAPIFolder
Dim intcount As Integer
Dim I As Long
Set myOlApp = CreateObject("Outlook.Application")
Set myNS = myOlApp.GetNamespace("MAPI")
Set fldNew = myNS.Folders(CurrentFolder.Name)
Set olTempItem = CurrentFolder.Items
Set myRestrictItems = olTempItem.Restrict("[ReceivedTime] < '" &
RestrictDate & "'")
If myRestrictItems.Count = 0 Then Exit Sub
intcount = myRestrictItems.Count
For I = intcount To 1 Step -1
Set olTempItem = myRestrictItems(I)
If olTempItem.FlagStatus > 0 Then olTempItem.FlagStatus = 0
olTempItem.Move(fldNew)
Next
End Sub
works fine except when it hits a read reciept or an admistrative bounce back
message. If it hits either of these it throws and error # 424 "Object
required"
Any ideas on how I might be able to move the report items?
Thanks for any suggestions you might have.
Steve
Private Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder, RestrictDate
As Date)
Dim olTempItem As Object
Dim myOlApp As New Outlook.Application
Dim myNS As Outlook.NameSpace
Dim myRestrictItems As Items
Dim fldNew As Outlook.MAPIFolder
Dim intcount As Integer
Dim I As Long
Set myOlApp = CreateObject("Outlook.Application")
Set myNS = myOlApp.GetNamespace("MAPI")
Set fldNew = myNS.Folders(CurrentFolder.Name)
Set olTempItem = CurrentFolder.Items
Set myRestrictItems = olTempItem.Restrict("[ReceivedTime] < '" &
RestrictDate & "'")
If myRestrictItems.Count = 0 Then Exit Sub
intcount = myRestrictItems.Count
For I = intcount To 1 Step -1
Set olTempItem = myRestrictItems(I)
If olTempItem.FlagStatus > 0 Then olTempItem.FlagStatus = 0
olTempItem.Move(fldNew)
Next
End Sub