How to Auto Create a Task whenever a Specific Category Is Assigned to an Email in Outlook

This article will teach you how to automatically create a new task when you assign a specific color category to an email by means of Outlook VBA.

In the past, when I received an email involved with a task, I used to specify the “Task” category to this email and proceed to create a new related task. To be honest, this process is indeed time-consuming. I have to write down all the info in advance, since that these details must be demanded in the new task. But now, with the help of VBA, Outlook can automatically create a new task whenever I specify the “Task” category to an email. If you’re interested in this tip, read on to get them in detail.

Auto Create a Task Whenever a Specific Category Is Assigned to an Email

  1. To start with, launch Outlook and switch to “Developer” tab.
  2. On this tab, you can find and click on the “Visual Basic” button.
  3. Then a new window of “Microsoft Visual Basic for Applications” will open up. In it, you ought to double click on “ThisOutlookSession” project.
  4. Next you should copy the following VBA codes into the “ThisOutlookSession” project window.
Public WithEvents OlItems As Outlook.Items

Sub Application_Startup()
    Set OlItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Sub OlItems_ItemChange(ByVal Item As Object)
    Dim obApp As Application
    Dim olTask As TaskItem

    If Item.Class = olMail And Item.Categories = "Task" Then
       Set obApp = Outlook.Application
       Set olTask = obApp.CreateItem(olTaskItem)
       With olTask
            .Subject = Item.Subject
            .Body = Item.Body
            .Attachments.Add Item
            .StartDate = Now
            .DueDate = Now + 3
            .Save
            .Display
       End With
    End If
 
    'To clear the category
    'If you want to keep the category, remove the following four lines
    With Item
         .Categories = ""
         .Save
    End With
 
    Set obApp = Nothing
    Set olTask = Nothing
End Sub

Copy and Paste the Codes in ThisOutlookSession

  1. After that, you would be required to sign this code. You can use Office built-in utility – “Digital Certificate for VBA Projects” to achieve it. For more detailed steps, you can refer to the Step 2 in this article “2 Steps to Auto Mark Junk Emails as Read in Outlook”.Digital Certificates for VBA Projects
  2. Later in order to prevent external malicious macro, you should turn to “Trust Center” and change the macro settings to enable digitally signed macros only.Change Macro Settings
  3. Eventually you can have a try.
  • Pitch on a mail item and assign a specific category to it, like the following screenshot:Assign the specific category to the email
  • At once, a new task will be created automatically and gets displayed in a new popup window.New Task

Keep Tabs on Malicious Macros in Suspected Emails

It is vitally important to block all the external un-signed macros, in that they may contain viruses or malware, which can damage your Outlook data with ease. So users should pay close attention to the emails which come along with macros. In addition, it is highly advisable to invest in a remarkable corrupt Outlook data fix tool, like DataNumen Outlook Repair. It can come to your rescue when you suffer unanticipated Outlook crash.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair SQL mdf error and outlook repair software products. For more information visit www.datanumen.com

One response to “How to Auto Create a Task whenever a Specific Category Is Assigned to an Email in Outlook”

Leave a Reply

Your email address will not be published. Required fields are marked *