How to move emails to specified folder after assigning certain category in Outlook?
Supposing you assigned a category to a received email in your Outlook, after assigning category, you want this email to move automatically to a certain email folder named with the category name. For example, an email assigned with category “Private” will be move to a folder name “Private” in your Outlook. How to achieve it? The method in this article can help you solve the problem with ease.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
The below VBA code can help to automatically move emails to specified folder after assigning certain category in Outlook. Please do as follows.
1. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, double click to open the ThisOutlookSession (Code) window. Then copy below VBA code into the window. See screenshot:
VBA code: Move emails to specified folder after assigning certain category
Private WithEvents xInboxFld As Outlook.Folder Private WithEvents xInboxItems As Outlook.Items Private Sub Application_Startup() Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox) Set xInboxItems = xInboxFld.Items End Sub Private Sub xInboxItems_ItemChange(ByVal Item As Object) Dim xMailItem As Outlook.MailItem Dim xFlds As Outlook.Folders Dim xFld As Outlook.Folder Dim xTargetFld As Outlook.Folder Dim xFlag As Boolean On Error Resume Next If Item.Class = olMail Then Set xMailItem = Item xFlag = False If xMailItem.Categories <> "" Then Set xFlds = Application.Session.GetDefaultFolder(olFolderInbox).Folders If xFlds.Count <> 0 Then For Each xFld In xFlds If xFld.Name = xMailItem.Categories Then xFlag = True End If Next End If If xFlag = False Then Application.Session.GetDefaultFolder(olFolderInbox).Folders.Add xMailItem.Categories, olFolderInbox End If Set xTargetFld = Application.Session.GetDefaultFolder(olFolderInbox).Folders(xMailItem.Categories) xMailItem.Move xTargetFld End If End If End Sub
3. Save the code and restart the Outlook.
4. From now on, when assigning category to a receiving email, a folder with the category name will be created automatically under the Inbox folder with the email moved in. See screenshot:
Note: All emails assigned with the same category will be moved to the same folder automatically. But if a new category is assigned to an email, a new folder will be created automatically.
- How to assign category to outgoing email in Outlook?
- How to keep original categories when replying or forwarding email in Outlook?
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 3 months agoThis worked for me. would you be able to edit the code just to have the messages moved to one folder instead of creating one for each category. I have all the emails in one folder regardless of category and sort them in the folder.
- To post as a guest, your comment is unpublished.· 5 months agoAt first this did not work for me either but after a while it just started to work, I'm not sure why though.
- To post as a guest, your comment is unpublished.· 1 years agosame here. Didn't work
- To post as a guest, your comment is unpublished.· 1 years agoDid not work.