|
OLKeeper
|
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails. |
With rules you can only look for your own address in the cc field in order to move the email. With this example you can look for any string in CC. If it's found, the email will be moved into a subfolder of the inbox. In this sample the folder is named 'test'.
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
MoveMessage Item
End If
End Sub
Private Sub MoveMessage(Item As Outlook.MailItem)
Dim Ns As Outlook.NameSpace
Dim Recipients As Outlook.Recipients
Dim Recip As Outlook.Recipient
Dim Folder As Outlook.MAPIFolder
Dim Find As String, FolderName As String
Find = "info"
FolderName = "test"
Set Recipients = Item.Recipients
For Each Recip In Recipients
If Recip.Type = olCC Then
If InStr(1, Recip.Address, Find, vbTextCompare) Then
Set Ns = Application.GetNamespace("MAPI")
Set Folder = Ns.GetDefaultFolder(olFolderInbox)
Set Folder = Folder.Folders(FolderName)
Item.Move Folder
Exit For
End If
End If
Next
End Sub