Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

March 29, 2004 12:00 AM

Outlook: Marking an Item with a Category

Windows IT Pro
InstantDoc ID #41945
Rating: (2)
Downloads
41945.zip

Can I place a button in the toolbar that will assign a specific message category to an item with one click?

Sure, that's easy. Just place the code that Listing 2, page 6, shows in a regular module in Outlook Visual Basic for Applications (VBA). If you're just getting started with Outlook VBA, Outlook VBA on Demand, "Back to Basics," August 2001, InstantDoc ID 21522, explains how to set the macro security level, get into the VBA programming environment, and create your first macro. The article also explains how to add a macro as a toolbar button.

Here are a few notes about the code:

  • The MarkA and MarkB procedures both call the same MarkWithCategory procedure, but each assigns a different category to the selected item. You can make as many individual category macros like this as you need or even create a separate Categories toolbar to hold a toolbar button for each macro.
  • GetCurrentItem() is a function that returns either an item selected in a folder view or an individual open item. Thus, you can use the MarkA and MarkB procedures from either a folder or an item window. You can also reuse GetCurrentItem() in any macro that you write to work with a selected or open item.
  • The MarkWithCategory procedure always appends the new category to the existing Categories value for the item. It doesn't check whether the category is already present. I haven't experienced any problems with having a category listed twice, but you could refine the code to check the existing Categories value to see whether a category is already present before adding it.
  • The objItem.Categories = ... statement in MarkWithCategory assumes that you're in some part of the world that uses the comma as the default list separator. If you're in a country that uses the semicolon or other separator, you need to replace the comma with that separator.

Related Content:

ARTICLE TOOLS

Comments
  • Brian
    5 years ago
    May 24, 2007

    Get a 404 error when trying to access VBA code

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.