How do I create a macro to close folders and clear the message fla

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using Outlook 2002. I use rules to move messages to folders and mark
them as read. I also indicate to clear the message flag, but it does not
always work. I would like to create a macro to run after the move that will
close the floder tree that contains the folder the message was moved to, and
again clear the message flag that pops up in the task bar.

Thanks,
 
To do this, you'd have to code the entire process by trapping the ItemAdd
event for your Inbox. However, unless you are using Exchange this event may
not fire if large numbers of messages are added/downloaded at the same time.

Regardless, you'd need to add code similar to the following to your
ThisOutlookSession module:

Option Explicit
Dim WithEvents NewMailItems As Outlook.Items

Private Sub Application_Quit()
Set NewMailItems = Nothing
End Sub

Private Sub Application_Startup()
Set NewMailItems =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub NewMailItems_ItemAdd(ByVal Item As Object)
'THIS WILL FIRE FOR EVERY NEW E-MAIL; YOU CAN USE THE
'Item OBJECT TO WORK WITH THE PROPERTIES OF THE E-MAIL MESSAGE

Dim objMail As Outlook.MailItem

If Item.Class <> olMail Then Exit Sub

Set objMail = Item
objMail.UnRead = False
objMail.FlagStatus = olNoFlag
End Sub
 
I appreciate your response, but I guess I have less programing skills than I
thought I would need. I am not sure how to find "ThisOutlookSession" module
and get the code modified correctly. Can you point me to a simpe example that
I can look at that shows the steps and syntax?

Thanks
BZ
 
Back
Top