How to create a custom rules using script to move old messages to shared/secondary mailbox? RRS feed

  • Question

  • Is it possible to mimic auto archive feature to use custom rule with script to move old messages to another shared mailbox/secondary mailbox along with filing/folder structure?

    Tuesday, July 14, 2015 5:15 PM


  • Hello,

    You can develop a VBA macro for moving mail items anywhere you need. The Move method of the MailItem class moves a Microsoft Outlook item to a new folder.

    Sub MoveItems() 
     Dim myNameSpace As Outlook.NameSpace 
     Dim myInbox As Outlook.Folder 
     Dim myDestFolder As Outlook.Folder 
     Dim myItems As Outlook.Items 
     Dim myItem As Object 
     Set myNameSpace = Application.GetNamespace("MAPI") 
     Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox) 
     Set myItems = myInbox.Items 
     Set myDestFolder = myInbox.Folders("Personal Mail") 
     Set myItem = myItems.Find("[SenderName] = Eugene Astafiev'") 
     While TypeName(myItem) <> "Nothing" 
     myItem.Move myDestFolder 
     Set myItem = myItems.FindNext 
    End Sub

    Tuesday, July 14, 2015 5:24 PM