Hi, i am trying to move all read emails that are unflagged to a subfolder.
Currently using this code:
-----------
Sub move2folder()
On Error Resume Next
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolderSrc = objNamespace.GetDefaultFolder(olFolderInbox)
Set objFolderDst = objFolderSrc.Folders("__gelesen")
Set colItems = objFolderSrc.Items
'Set colFilteredItems = colItems.Restrict("[UnRead] = False")
Set colFilteredItems = colItems.Restrict("[UnRead] = True and [FlagStatus] = 2")
For intMessage = colFilteredItems.Count To 1 Step -1
colFilteredItems(intMessage).Move objFolderDst
Next
End Sub
--------------
The line: Set colFilteredItems = colItems.Restrict("[UnRead] = False") works perfect when flagged / unflagged is unneccessary.
The line: Set colFilteredItems = colItems.Restrict("[UnRead] = True and [FlagStatus] = 2") does not do anything.
The code is from following page: Office Space: Filtering Email Messages in Microsoft Outlook
Any ideas as to how to get this to work?
No error message when executing the code - and no action.
Any help will be greatly appreciated.
Thanks,
Alex
Currently using this code:
-----------
Sub move2folder()
On Error Resume Next
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolderSrc = objNamespace.GetDefaultFolder(olFolderInbox)
Set objFolderDst = objFolderSrc.Folders("__gelesen")
Set colItems = objFolderSrc.Items
'Set colFilteredItems = colItems.Restrict("[UnRead] = False")
Set colFilteredItems = colItems.Restrict("[UnRead] = True and [FlagStatus] = 2")
For intMessage = colFilteredItems.Count To 1 Step -1
colFilteredItems(intMessage).Move objFolderDst
Next
End Sub
--------------
The line: Set colFilteredItems = colItems.Restrict("[UnRead] = False") works perfect when flagged / unflagged is unneccessary.
The line: Set colFilteredItems = colItems.Restrict("[UnRead] = True and [FlagStatus] = 2") does not do anything.
The code is from following page: Office Space: Filtering Email Messages in Microsoft Outlook
Any ideas as to how to get this to work?
No error message when executing the code - and no action.
Any help will be greatly appreciated.
Thanks,
Alex