How to use VBS to set categories for items in Outlook

3 years ago 261

If you miss Outlook categories, here's however to tally this VBScript process to get them back.

email.jpg

Image: istock/anyaberkut

Many Outlook users depended heavy connected the class diagnostic until it was removed. So, it was nary large astonishment erstwhile I started proceeding from readers and clients astir the loss. Fortunately, you tin reclaim the feature. If you privation to bash truthful manually, work Reclaim Outlook categories for IMAP accounts. This method works with immoderate unfastened Outlook item, not conscionable email messages. You tin bash the aforesaid happening with a VBScript procedure, which I find overmuch much businesslike than utilizing the manual route. In this article, I'll reappraisal a elemental process that automates reclaiming categories. I bash privation to accent that due to the fact that this diagnostic is nary longer supported, the process could halt moving astatine immoderate clip and without notice.

SEE: 83 Excel tips each idiosyncratic should master (TechRepublic)

I'm utilizing Microsoft 365 connected a Windows 10 system; this process isn't due successful the online Mail app. For your convenience, you tin download the .cls codification module.

The VBScript process successful Outlook

If you're acquainted with VBA but not VBScript, don't worry. VBS is simply a subset of VBA. Even if you're not acquainted with VBA, you shouldn't person immoderate occupation adding and moving this procedure. The sub process successful Listing A is highly simple. The lone drawback is that the Outlook point you are categorizing indispensable beryllium open.

Listing A

Public Sub SetCategory()

    'Displays class dialog truthful idiosyncratic can

    'set class to unfastened item.

    'If class is unused, diagnostic volition prompt

    'for shortcut cardinal selection.

    Dim OLItem As Object

    'Quits process if nary point is open.

    On Error GoTo ErrorHandler

    Set OLItem = Application.ActiveInspector.CurrentItem

    OLItem.ShowCategoriesDialog

    Exit Sub

ErrorHandler:

    MsgBox "Please unfastened the point you privation to categorize.", vbOKOnly, "Error"

    Exit Sub

End Sub

First, the codification creates an Object adaptable named OLItem and sets it to the progressive (open) item. You tin usage this process to categorize immoderate Outlook object—but it indispensable beryllium unfastened for the process to work. The last enactment displays the Categories dialog, truthful you tin acceptable a class for the existent item, OLItem. That's each the process does, but you'll proceed by checking a class (color). If that class hasn't been utilized before, the diagnostic (not the code) volition punctual you to acceptable a keystroke shortcut. You tin bash truthful oregon cancel that prompt.

There is simply a spot of error-handling for those times erstwhile nary point is open. The codification volition show a informing connection container and past discontinue the procedure.

SEE: Windows 11: Tips connected installation, information and much (free PDF) (TechRepublic)

To participate the procedure, property Alt + F11 to unfastened the Visual Basic Editor. In the Project Explorer to the left, prime ThisOutlookSession truthful you tin tally the process successful immoderate window. You tin participate the codification manually oregon import the downloadable .cls file. If you participate the codification manually, don't paste from this web page. Instead, transcript the codification into a substance exertion and past paste that codification into the ThisOutlookSession module. Doing truthful volition region immoderate phantom web characters that mightiness different origin errors.

How to usage the process successful Outlook

Before moving the procedure, cheque the information mounting by clicking the File tab and past choosing Options. At the bottommost of the near pane, click Trust Center and past click Trust Center Settings successful the dialog. In the near pane, click Macro Settings. You'll person 4 options. Click 1 of the 3 options that let you to execute macros, arsenic shown successful Figure A. Your level oregon extortion depends connected you and your organization; I chose Notification for All Macros. Click OK twice. If you person to alteration this option, adjacent and restart Outlook earlier you continue.

Figure A

outlookvbssetcategory-a1.jpg

  Choose a information enactment that allows VBScript procedures.

Now, let's execute the process arsenic follows:

  1. Open an existing email.
  2. Click the Developer tab (if you don't spot the Developer tab, spot "How to adhd the Developer tab" below).
  3. In the Macros group, click Macros.
  4. From the dropdown, click SetCategory (Figure B) and click Run.
  5. In the resulting dialog, take a class color, specified arsenic blue. If bluish hasn't been chosen before, the diagnostic (not the code) opens a 2nd dialog that allows you to sanction the class and acceptable a shortcut. Otherwise, click the Shortcut Key dropdown and take the shortcut Ctrl + F2 (Figure C).
  6. The diagnostic applies the bluish class (Figure D).

Figure B

outlookvbssetcategory-b-2.jpg

  Execute the process SetCategory.

Figure C

outlookvbssetcategory-c.jpg

  Choose a class (by color) and past acceptable a keyboard shortcut.

Figure D

outlookvbssetcategory-d.jpg

  The bluish portion beneath the header accusation is the ocular confirmation that you've categorized this email.

You tin adjacent the email erstwhile you like; it's categorized arsenic blue. To region the category, unfastened the item, right-click the class colour enactment and take Clear Category.

Add the Developer tab

If you don't spot the Developer tab, you tin rapidly show it arsenic follows:

  1. Click the Quick Access Toolbar dropdown and take More Commands.
  2. Click Customize Ribbon successful the near pane.
  3. In the database to the right, cheque Developer, arsenic shown successful Figure E.
  4. Click OK.

Figure E

outlookvbssetcategory-e.jpg

  Add the Developer tab to the ribbon.

It's improbable that you'll privation to enactment done each those steps each clip you privation to tally the procedure. Instead, adhd the macro to the Quick Access Toolbar. To bash so, read How to adhd Office macros to the QAT toolbar for speedy access.

Microsoft Weekly Newsletter

Be your company's Microsoft insider by speechmaking these Windows and Office tips, tricks, and cheat sheets. Delivered Mondays and Wednesdays

Sign up today

Also see

Read Entire Article