When replying or forwarding an email, you may want to apply the same categories. In this article, we will teach you to realize this with VBA code.
If you are accustomed to assigning the same color categories of original email to all of its replies and forwards, why don’t you let Outlook auto achieve this? Even though Outlook does not provide such a direct feature, you still can get it with the help of VBA code. In the followings, we will expose the detailed steps and code to you.
Auto Apply the Categories of an Email to All Its Replies and Forwards
- At the very outset, launch Outlook application.
- Then, press “Alt + F11” keys to run Outlook VBA editor.
- Next, copy the following VBA code into “ThisOutlookSession” project.
Private WithEvents objExplorer As Outlook.Explorer Private WithEvents objInspectors As Outlook.Inspectors Private WithEvents objMail As Outlook.MailItem Private strCategories As String Private Sub Application_Startup() Set objExplorer = Outlook.Application.ActiveExplorer Set objInspectors = Outlook.Application.Inspectors End Sub Private Sub objExplorer_SelectionChange() On Error Resume Next If objExplorer.Selection.Item(1).Class = olMail Then Set objMail = objExplorer.Selection.Item(1) strCategories = objMail.Categories End If End Sub Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector) If Inspector.CurrentItem.Class = olMail Then Set objMail = Inspector.CurrentItem strCategories = objMail.Categories End If End Sub Private Sub objMail_Forward(ByVal Forward As Object, Cancel As Boolean) Call CopyCategories(Forward) End Sub Private Sub objMail_Reply(ByVal Response As Object, Cancel As Boolean) Call CopyCategories(Response) End Sub Private Sub objMail_ReplyAll(ByVal Response As Object, Cancel As Boolean) Call CopyCategories(Response) End Sub Private Sub CopyCategories(ByVal objNewMail As Object) objNewMail.Categories = strCategories End Sub
- After that, restart your Outlook to activate this project.
- Since then, you can try it by following the steps below.
- First off, select an email and hit “Forward” button.
- Then, a forwarding email will display, in which you can shift to “Options” tab and hit the extension icon in the lower right corner of “More Options” group.
- Next, in the popup “Properties” dialog box, you can see that this email is assigned with the same color categories as the original email.
Fix Damaged Outlook File
Given the fact that Outlook is vulnerable, you have to take a lot of actions to avoid Outlook data loss. For example, you need to make periodical data backups. Plus, it is necessary for you to beware of unknown emails including the embedded links or attachments. Last but not least, you ought to get hold of a tip-top external fix tool, like DataNumen Outlook Repair. It is able to help you to retrieve maximum data from corrupt Outlook file.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including SQL Server fix and outlook repair software products. For more information visit www.datanumen.com