|Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.|
Outlook autoamtically calls the ItemAdd function as soon as an item is added to the inbox. The macro then looks for a certain phrase in the subject of the email and if found, moves the email to a determined subfolder of the inbox.
The rules are set in the Application_Startup procedure: The first term, for instance, 'Test' is the one that is searched in the subject, the second term, for instance, 'Folder 1' is the name of the target folder. In this sample that must be an existing subfolder of your inbox.
Private WithEvents InboxItems As Outlook.Items Private m_Rules As Variant Sub Application_Startup() Dim i As Long i = -1: ReDim m_Rules(1000) i = i + 1: m_Rules(i) = Array("Test", "Ordner 1") i = i + 1: m_Rules(i) = Array("test", "Ordner 2") 'more rules can follow here '... 'done ReDim Preserve m_Rules(i) Set InboxItems = Application.Session.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub InboxItems_ItemAdd(ByVal Item As Object) Dim Folder As Outlook.MAPIFolder Dim i As Long, Find As String Find = Item.Subject For i = 0 To UBound(m_Rules) If InStr(1, Find, m_Rules(i)(0), vbBinaryCompare) Then Set Folder = Application.Session.GetDefaultFolder(olFolderInbox) Set Folder = Folder.Folders(m_Rules(i)(1)) Item.Move Folder Exit For End If Next End Sub
|ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.|