Moving bounce notices to PST file fails

  • Thread starter Thread starter Steve Roberts
  • Start date Start date
S

Steve Roberts

I have a program that moves email from a public folder to a .PST file if the
email is older than X. The problem I am having is that the users have
decided that they should put any bounced email messages into the public
folder as well. When my program tries to move the bounce back message, it
errors 424 Object Required. The program works on everything else. Are the
bounce back messages not actually a message object?

Any Ideas?

Thanks

Steve
 
Private Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder,
RestrictDate As Date)

Dim olNewFolder As Outlook.MAPIFolder
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 olNewFolder = CurrentFolder
Set olTempItem = CurrentFolder.items
Set myOlApp = CreateObject("Outlook.Application")
Set myNS = myOlApp.GetNamespace("MAPI")
Set myRestrictItems = olTempItem.Restrict("[ReceivedTime] < '" &
RestrictDate & "'") 'olTempItem.Restrict("[ReceivedTime] < '1/2/2004'")
Set fldNew = myNS.Folders(CurrentFolder.Name)

If myRestrictItems.Count = 0 Then Exit Sub
intcount = myRestrictItems.Count

For I = intcount To 1 Step -1

Set olTempItem = myRestrictItems(I)

'********************************************
'If the Flag Status was changed in the user's inbox then the email
is moved to the public folders outlook thinks the item hasn'e been processed
and throws an error
If olTempItem.FlagStatus > 0 Then olTempItem.FlagStatus = 0
'********************************************

'****************************************************
'Here is the move code

olTempItem.Move (fldNew)

'****************************************************

Next



End Sub
 
Works just fine here. Do you mean the error happens at the Move() line or at
some later time?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Steve Roberts said:
Private Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder,
RestrictDate As Date)

Dim olNewFolder As Outlook.MAPIFolder
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 olNewFolder = CurrentFolder
Set olTempItem = CurrentFolder.items
Set myOlApp = CreateObject("Outlook.Application")
Set myNS = myOlApp.GetNamespace("MAPI")
Set myRestrictItems = olTempItem.Restrict("[ReceivedTime] < '" &
RestrictDate & "'") 'olTempItem.Restrict("[ReceivedTime] < '1/2/2004'")
Set fldNew = myNS.Folders(CurrentFolder.Name)

If myRestrictItems.Count = 0 Then Exit Sub
intcount = myRestrictItems.Count

For I = intcount To 1 Step -1

Set olTempItem = myRestrictItems(I)

'********************************************
'If the Flag Status was changed in the user's inbox then the email
is moved to the public folders outlook thinks the item hasn'e been
processed and throws an error
If olTempItem.FlagStatus > 0 Then olTempItem.FlagStatus = 0
'********************************************

'****************************************************
'Here is the move code

olTempItem.Move (fldNew)

'****************************************************

Next



End Sub


Dmitry Streblechenko said:
They are ReportItem objects, not MailItem in the Outlook Object Model.
What is the code?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top