Since there haven't been any replies or comments, I'm not sure if what I've learned and coded has been useful to anyone, but I feel technically obligated at this point to complete the solution and share it with the forum. I know if you're anything like me, once you find the solution you're looking for, you leverage the code and move on without a thought about the individual who made your life a little easier. Sometimes, it gets very lonely in cyberspace.
Anyways, I've completed the entire solution I was seeking when I asked it in my first post. I used the same test scenario in my post #3. So, there were over 20 messages in the 'SI' folder when I restarted Outlook with the macro below in place within ThisOutlookSession.
Here's what happens: When you first launch Outlook 2010, the splash banner appears and you'll see what Outlook is loading as it loads. My macro gets processed immediately after I see 'Loading Profiles' during the next item which just says 'Processing' with animated, serially recurring ellipses (...) following the word. Since this is processing on an IMAP server, it takes several seconds to complete. Once it's done, Outlook finishes loading normally. I checked the 'SI' folder and all test messages were processed exactly as I desired.
Here's all the code I placed in ThisOutlook Session. Modify to suit your purpose.
Private Sub Application_MAPILogonComplete()
RemoveOldSI
End Sub
Private Sub RemoveOldSI()
'Deletes messages from Sports Illustrated that have "SI Extra: "
'in the subject line and are older than 1 week.
Dim olSession As Outlook.Application, olNamespace As NameSpace
Dim olInbox As Outlook.MAPIFolder
Dim olOtherInbox As Outlook.MAPIFolder
Dim olFolder As MAPIFolder
Dim SI_Items As Items
Dim i As Integer
Set olSession = New Outlook.Application
Set olNamespace = olSession.GetNamespace("MAPI")
Set olInbox = olNamespace.GetDefaultFolder(olFolderInbox)
Set olOtherInbox = Session.Folders("MyGmailAccountName@gmail.com")
Set olFolder = olOtherInbox.Folders("SI")
Set SI_Items = olFolder.Items
For i = SI_Items.Count To 1 Step -1
If TypeName(SI_Items.Item(i)) = "MailItem" Then
If InStr(1, SI_Items.Item(i).Subject, "SI Extra: ", vbTextCompare) _
And InStr(1, SI_Items.Item(i).SenderName, "Sports Illustrated", vbTextCompare) Then
If Date - SI_Items.Item(i).ReceivedTime > 6 Then SI_Items.Item(i).Delete
End If
End If
Next
Set olSession = Nothing
Set olNamespace = Nothing
Set olInbox = Nothing
Set olOtherInbox = Nothing
Set olFolder = Nothing
Set SI_Items = Nothing
End Sub
This will be my final post on this thread, unless someone/anyone has questions or comments. I hope it will make someone's day when they find this in a search. Bring on the Karma!!!
-dougbert