Try the code below. Just change anything you need to in the calling MyMacro
procedure:
Sub MyMacro()
On Error GoTo MyMacro_Error
Dim objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
SearchFolderForMessagesFlaggedForFollowUpBeforeSpecifiedDate objInbox,
#01/30/2005#
Set objNS = Nothing
Set objInbox = Nothing
On Error GoTo 0
Exit Sub
MyMacro_Error:
If Err.Number <> 0 Then
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure MyMacro of VBA Document ThisOutlookSession"
Resume Next
End If
End Sub
Sub SearchFolderForMessagesFlaggedForFollowUpBeforeSpecifiedDate(MailFolder
As Outlook.MAPIFolder, BeforeDate As Date)
On Error GoTo
SearchFolderForMessagesFlaggedForFollowUpBeforeSpecifiedDate_Error
Dim objItems As Outlook.Items, objMailItem As Outlook.MailItem
Dim strCriteria As String
strCriteria = "[ReceivedTime] <= """ & BeforeDate & """ AND
[FlagRequest] = 'Follow up' AND [FlagStatus] <> 1"
Set objItems = MailFolder.Items.Restrict(strCriteria)
For Each objMailItem In objItems
objMailItem.FlagStatus = olFlagComplete
objMailItem.Save
Next
On Error GoTo 0
Exit Sub
Set objItems = Nothing
Set objMailItem = Nothing
SearchFolderForMessagesFlaggedForFollowUpBeforeSpecifiedDate_Error:
If Err.Number <> 0 Then
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure SearchFolderForMessagesFlaggedForFollowUpBeforeSpecifiedDate of VBA
Document ThisOutlookSession"
Resume Next
End If
End Sub
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
--
Job:
http://www.imaginets.com
Blog:
http://blogs.officezealot.com/legault/
Kevin said:
Using Outlook 2000, I'm trying to write a macro that searches through
messages in the inbox and, if they are older than 01/30/2005 and flagged for
follow up, I want to flag them complete.
I've tried several approaches but don't seem to be getting anywhere. Does
anyone have some code that can do this?
Thanks.
Kevin