Set objWatchFolder = objNS.GetDefaultFolder(olFolderInbox).Folders("My Folder") Set objNS = Application.GetNamespace("MAPI") See Working with VBA and non-default Outlook Folders for code samples to use other folders. ![]() This version of the macro watches a specific folder for new items, in this example it is watching a subfolder under the Inbox. If objVariant.Subject = Item.Subject And objVariant.SentOn < Item.SentOn Then If objVariant.MessageClass = "IPM.Note" Then ' Remove these lines if you don't want to add a categoryįor intCount = To 1 Step -1 Set objInbox = Session.GetDefaultFolder(olFolderInbox) Sub DeleteOlderMessages(Item As Outlook.MailItem) See Outlook's Rules and Alerts: Run a Script for more information on using Run A Script rules. ![]() ![]() While it only runs if Outlook is open, old messages won't pile up, as it deletes all older messages that meet the conditions when Outlook is open.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |