Outlook: Move Items to Folder (with GUI folder list and not inputbox)
I was searching for a Macro online for Outlook mail items moved to different folders.
Have seen few codes that performs the same but with this code I used the GUI folder listing instead of prompting for an inputbox to avoid errors as most users are not aware of the Folder paths.
I submitted the code to OutlookCodeDotCom: Moving mail items to specified folder
It has 30++ downloads so far... not bad!
- Sub MoveMailToFolders()
- Dim objNS As Outlook.NameSpace
- Dim MyFolder As Outlook.MAPIFolder
- Dim objItem As Outlook.MailItem
- Dim ctr As Integer
- On Error Resume Next
- ctr = 0
- Set objNS = Application.GetNamespace("MAPI")
- Set MyFolder = objNS.PickFolder
- MsgBox "The selected mail item(s) will be moved to: " & vbCrLf & vbCrLf & _
- "Folder Path: " & MyFolder.FolderPath & vbCrLf & _
- "Folder Name: " & MyFolder.Name _
- , vbOKOnly + vbInformation, "Outlook Help"
- For Each objItem In Application.ActiveExplorer.Selection
- If MyFolder.DefaultItemType = olMailItem Then
- If objItem.Class = olMail Then
- ctr = ctr + 1
- objItem.Move MyFolder
- End If
- End If
- Next
- MsgBox "Moved: " & ctr & " mail item(s) to: " & MyFolder.Name, vbInformation, "Outlook Help"
- Set objNS = Nothing
- Set MyFolder = Nothing
- End Sub
Then using the Customize option on the toolbar, you can create a button for the Macro and assign a shortcut key to it!
If at first you fail, call it version 1.0