Moving a Mix of Mail Items and Report Items

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
 
E

Eric Legault [MVP - Outlook]

The error is likely due to certain properties not being available on those
kinds of item types. Before doing anything more with olTempItem, check that
olTempItem.Class = olMail before doing anything else with it. You can also
check that olTempItem.MessageClass = "IPM.Note" as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top