Automatically Categorize a New Appointment

For users of smartphones, for instance, that don't support categories see how to categorize every new appointment.

Last modified: 2009/09/23 | Accessed: 68.905  | #76
◀ Previous sample Next sample ▶
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.

If you organize your Outlook items by categories and synchronize with a smartphone that doesn't support categories, either your data organization gets mixed up, or you have to update it manually after any sync. Users who sync the Outlook calendar with the Google calendar via SyncMyCal face the same issue.

This example demonstrates how to assign a certain category to any new appointment if it's marked private, or vice versa, mark an appointment private if a certain category is assigned. You just need to replace the category name Sample by any name of your choice.

tip  How to add macros to Outlook
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace

  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  Dim Appt As Outlook.AppointmentItem
  Dim CategoryName as String

  CategoryName = "Sample"

  If TypeOf Item Is Outlook.AppointmentItem Then
    Set Appt = Item
    If Appt.Sensitivity = olPrivate Then
      If Appt.Categories = "" Then
        Appt.Categories = CategoryName
      End If
    ElseIf InStr(1, Appt.Categories, CategoryName, vbTextCompare) Then
      Appt.Sensitivity = olPrivate
    End If
  End If
End Su
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.
email  Send a message