Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


March 29, 2004

Outlook: Marking an Item with a Category

RSS
Subscribe to Windows IT Pro | See More Exchange Server and Outlook Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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.

End of Article



Reader Comments
Get a 404 error when trying to access VBA code

bmajerus May 24, 2007 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...


Exchange Server and Outlook Whitepapers Email Controls and Regulatory Compliance

Take Control of Your Email: Understand the Business Reasons for Email Storage Management

Related Events Bail Out Your Exchange Environment

Continuous Application Virtualization: An Answer to Exchange Recovery Problems

Check out our list of Free Email Newsletters!

Exchange Server and Outlook eBooks Spam Fighting and Email Security for the 21st Century

Understanding and Leveraging Code Signing Technologies

The Expert's Guide for Exchange 2003: Preparing for, Moving to, and Supporting Exchange Server 2003

Related Exchange Server and Outlook Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

Exchange & Outlook UPDATE eNewsletter
News, strategies, products, and developments in Exchange Server and Outlook messaging.

Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement