Need a script to organize my mails in Outlook

Hi Experts i found a script on http://www.slipstick.com/developer/delete-older-messages-new-message-arrives/

Sub DeleteOlderMessages(Item As Outlook.MailItem)
 
Dim objInbox As Outlook.MAPIFolder
Dim intCount As Integer
Dim objVariant As Variant
 
Set objInbox = Session.GetDefaultFolder(olFolderInbox)
 
' Remove these lines if you don't want to add a category
Item.Categories = "Delete Older"
Item.Save
 
For intCount = objInbox.Items.Count To 1 Step -1
 Set objVariant = objInbox.Items.Item(intCount)
 If objVariant.MessageClass = "IPM.Note" Then
    If objVariant.Subject = Item.Subject And objVariant.SentOn < Item.SentOn Then
     objVariant.Delete
     Else
    End If
 End If
Next
 
Set objInbox = Nothing
End Sub

This will delete Mails with the same subject. I am in the need for the similar situation but my subjects are in one word different.

Explaination: I am getting from nagios status mails. I can not access directly to the system so i need to keep track of the status. So my idea is to have a rule set like this:
1.) when mail arrive i move them to a folder named like the system
2.) if in the subject is ** PROBLEM then it should keep it
3.) if in the subject is ** RESOLVED it should remove both the ** Problem one and the ** RESOLVED one

Can someone help me out?
If necessary i can install a tool instead of the rules in Outlook. But i did not find any tool what is doing that.
I have no access to exchange itself so i need a client solution.
LVL 8
Wilder_AdminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
So there will never be more than two messages in a given system's folder?
0
Nick67Commented:
The guts of what you need are here
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
   ' Reference the items in the Inbox. Because myOlItems is declared
   ' "WithEvents" the ItemAdd event will fire below.
   Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
      ' Check to make sure it is an Outlook mail message, otherwise
      ' subsequent code will probably fail depending on what type
      ' of item it is.
      If TypeName(Item) = "MailItem" Then
            Select Case True
                 Case Item.Subject Like "** PROBLEM"
                      'code to move the item to a particular folder
                 Case Item.Subject Like "** RESOLVED"
                      'code to search a particular folder for an item with subject like "** PROBLEM"
                      'if found, that item is deleted and the resolved email is also deleted.
                 Case Else
                       'any code you may want to fire in the event of mailings without the critical words
        End Select
      End If
End Sub

Open in new window


If you need more help, more detail about the subjects of the items, and the folders will be required.
I can't code for what I have no information about.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.