Update! This book about Outlook 2007 programming is now available in a Kindle edition.

This is an old project, and I am no longer doing work in this field, but I maintain the information here because many people are still interested in it. If you are looking with assistance with Outlook issues, please see Looking for Outlook Help? for suggestions. And thanks for visiting! I hope you check out some of my current projects and interests.

-- Sue Mosher

Microsoft Outlook 2007 Programming

Microsoft Outlook 2007 Programming by Sue Mosher unleashes the flexibility of Outlook 2007, allowing administrators and end users to customize Outlook in the same way they've used macros and templates to customize other applications like Excel and Word. Network administrators will learn to design their own Outlook forms and generate reports on key Outlook settings. Power users will discover how VBA can automate repetitive tasks and tailor Outlook's functionality to their own procedures. 

ol2007 book.jpg

Microsoft Outlook 2007 Programming by Sue Mosher unleashes the flexibility of Outlook 2007, allowing administrators and end users to customize Outlook in the same way they've used macros and templates to customize other applications like Excel and Word. Network administrators will learn to design their own Outlook forms and generate reports on key Outlook settings. Power users will discover how VBA can automate repetitive tasks and tailor Outlook's functionality to their own procedures. 

ISBN: 1555583460, published by Digital Press, leading publishers of books on Exchange, Outlook, and other messaging issues. Other ordering links:

Amazon.com
Amazon.co.uk
ScienceDirect (as eBook in PDF format)

As a convenience to readers, the source code for the samples included in the book is available for download here (897kb .zip file).

Chapter 1: What you can do with Outlook 

Why program with Outlook?

Outlook programming tools

Visual Basic for Applications

Custom Outlook forms

Visual Basic Scripting edition

Folder home pages

Office integration and other object models

How to start

Key Outlook programming components

Showing developer commands

Where’s the .NET code?

Chapter 2: The VBA Design Environment

VBA: The Basics

VBA security

Starting VBA

Saving your work and ending a VBA session

VBA windows

Project Explorer

Properties window

VBA user forms

Modules

Object Browser

Getting Help in VBA

Working with VBA projects

Backing up your work

Signing your project

Distributing VBA code to others

Chapter 3: Building Your First VBA Form

Understanding Outlook birthdays and anniversaries

Step 1: What controls do you need?

Step 2: Create the form

Exploring form properties

Should you use a modal or modeless form?

Step 3: Add user input controls

Step 4: Add command buttons

Basic command button properties

Adding code

Anatomy of a procedure

Step 5: Plan the next development stage

More on VBA form controls

Check box controls

Option buttons

List box and combo box controls

Accelerators and tab order

Chapter 4: Introducing Outlook Forms

Understanding the two types of custom forms

Starting the forms designer

The six standard Outlook forms

The contact form

The appointment form

The task form

The journal entry form

The message form

The post form

Additional forms

Common form pages

When to use which form

Working in the forms designer

Controls and the Control Toolbox

The Field Chooser

Getting forms design Help

Saving forms and ending a design session

Understanding published forms

Understanding .oft form template files

Creating your first custom contact form

Adding fields

Rearranging controls

Showing, hiding, and renaming pages

Setting control properties

Testing the form

Setting form properties

Saving and publishing the form

Using the form

Chapter 5: Introducing Form Regions

Understanding form regions

Controls for form regions

Creating your first form region

Registering and deploying form regions

Other form region manifest settings

Other considerations for deploying form regions

Limitations of form regions

Other ideas for form regions

Chapter 6: Extending Form Design with Fields and Controls

Understanding fields versus controls

Creating user-defined fields

Field types

Combination fields

Formula fields

Working with formula and combination fields

Example: Calculate a contact’s age

Adding and removing fields on Outlook forms

Binding a control to a field

Initial value

Simple validation

Validation formulas

Validation formula messages

Using form controls

Text boxes

Command buttons

Check boxes

Option buttons

Frames

List box and combo box controls

Spin button

Multi-page control

Image control

Outlook View Control

Some control and field limitations

Laying out compose and read pages

Chapter 7: Code Basics

Understanding when VBA code runs

VBA form events

What is a Sub anyway?

VBA Application-level events

VBA code modules

Macros to run programs on demand

“Run a script” rule procedures

Writing VBA Code

Variables

Outlook properties and methods

Subroutines versus functions

Operators

Referring to VBA forms and controls

Writing VBScript Code for Outlook forms

Declaring constants and variables

Custom form events

Adding VBScript code to an Outlook form

Cancelling events

Referring to Outlook form controls

Referring to Outlook item properties

Working with custom keywords properties

Creating custom properties programmatically

Writing Other Outlook Automation Code

Starting an Outlook Session

Limitations on Outlook automation

Chapter 8: Code Grammar 101

Option Explicit

Declaring variables and constants

Variable data types

Variable naming conventions

Understanding scope

Declaring constants

Writing procedures

Calling procedures

Passing arguments

Adding data types to parameters and functions

Making code reusable

Documenting your procedures

More code style tips

Working with Expressions and Functions

Elements of an expression

Using mathematical expressions

Working with strings

Extracting string parts

Comparing strings

Replacing parts of a string

Other useful string functions

Example: Parsing text from a structured text block

Working with dates and times

Basic date-related functions

Date extraction functions

Performing date arithmetic

Time zones and international dates

Using arrays, dictionaries, and the Split() and Join() functions

Working with multidimensional arrays

Building and using dictionaries

Exampe: Parsing structured text with an array and a dictionary

Controlling program flow

If … Then statements

Select Case statements

Do loops

For … Next loops

Example: Handling multiselect list boxes

For Each … Next loops for collections

GoTo statements

Providing feedback

Feedback with message boxes

Feedback with VBA forms

Example: Adding feedback to the birthday/anniversary reminder form

Getting user input

Using message boxes

Using input boxes

Using VBA forms

Working with files and other objects

Adding programming library references in VBA

Using the Scripting Runtime library

Using Windows Script Host techniques

Chapter 9: Handling Errors, Testing and Debugging

Understanding errors

Simple syntax errors

Compile errors

Runtime errors

Logic errors

Outlook bugs

Testing and debugging in VBA

Using breakpoints

Working in break mode

Using the Immediate window

Continuing program execution

Adding VBA error handlers

Debugging Outlook form VBScript code

Error handing in VBScript

Using the script debugger

Using VBA to prototype VBScript code

A recipe for VBA to VBScript code conversion

Chapter 10: Outlook Programming Basics

Introducing the Outlook object model

Launching the VBA Object Browser

Searching for objects and getting help

Outlook object and collection code techniques

Item method

Add method

Remove method

Example: Creating a voting button message

Releasing objects

Understanding Outlook security

Automation security

Form security

Attachment security

HTML message security

Folder home page security

Chapter 11: Responding to Outlook Events in VBA

Application object events

Using the Startup, MAPILogonComplete, and Quit events

Using NewMail and NewMailEx to handle incoming mail

Using the ItemSend event

Sidebar: Why doesn’t ItemSend always work?

Using the ItemLoad event

Writing handlers for other object events

Handling events in ThisOutlookSession

Handling events in class modules

Explorers and Explorer events

Example: Controlling the state of new folder windows

Example: Setting a default folder view

Inspectors and Inspector events

Example: Start the journal timer automatically

Example: Set a reminder on new all-day events

Folders, Folder, and Items events

Limitations of Items events

Example: Adding birthday and anniversary reminders

Processing incoming mail

Using a “run a script” rule

Using Application.NewMailEx

Using Items.ItemAdd

Using Application.Reminder and Reminders events

Example: Don’t snooze important reminders

Example: Processing messages and running other code on a schedule

Chapter 12: Coding Key Custom Form Scenarios

Working with Outlook item events

Understanding item event order

Preventing the user from making changes in a folder view

Locking an item for changes

Responding to user input on forms

Using the PropertyChange and CustomPropertyChange events

Handling Click events from unbound controls

Example: Creating a hyperlink on an Outlook form

Performing validation in Outlook form code

Example: A custom contact form with required categories

Handling form and control state issues

Checking item state in the Open

Storing and restoring control state

Handling state in a folder-based workflow

Chapter 13: Working with Stores, Explorers, and Folders

Information store concepts

Information store techniques

Adding a Personal Folders .pst file store

Removing a .pst store

Renaming a .pst store

Working with Explorers

Basic view techniques for Explorer windows

Setting the currently displayed folder

Accessing folders

Getting a default folder

Getting the current folder

Letting the user choose a folder

Example: Setting the save folder for a message

Getting a default folder from another Exchange mailbox

Getting a search folder

Walking the folder tree to get any folder

Returning an Exchange public folder

Returning shared folders using the navigation pane

Recursing folders

Working with folders

Working with folder properties

Creating and deleting folders

Moving and copying folders

Sharing a folder

Chapter 14: Using PropertyAccessor and StorageItem

Using the PropertyAccessor object

Example: Send a spam report

Where to find property schema names

Example: Set the default message class on a folder

Understanding PropertyAccessor vs. UserProperties

PropertyAccessor limitations and errors

Using the StorageItem object

StorageItem limitations

Example: Clean up one-off folder views

Chapter 15: Working with Inspectors and Items

Working with Inspectors

Creating items

Creating a new standard item

Creating a new item from a custom form

Creating a new item from an .oft template

Creating a new item from a vCard, iCalendar, or .msg file

Creating a new message from a Word or Excel document

Accessing items

Working with selected items

Getting the current item

Getting a particular item

Working with all the items in a folder

Example: Generate the next number in a sequence

Using the Table object

Example: Fill a list box from a Table

Example: Report on message response times

Using Item methods

Chapter 16: Searching for Outlook Items

Introduction to Outlook search methods

Building search strings

Using the Jet search syntax

Sidebar: Using the Query Building

Using the DASL search syntax

Searching for indexed content

Searching on item bodies, text, and keyword properties

Searching on date/time fields

Searching with custom properties

Using Items.Find and Items.Restrict

Using Table.FindRow and Table.Restrict

Using Explorer.Search

Using Application.AdvancedSearch

Example: Update all birthday and anniversary events

Creating a new search folder

Chapter 17: Working with Item Bodies

Basic item body techniques

Parsing text from a message body

Adding text to an item

Adding text to the Body property

Adding text to the HTMLBody property

Creating a formatted message

Creating an HTML-format message from a file

Sidebar: When you need to render an HTML message in the browser

Creating a message from a boilerplate template

Using WordEditor

Moving around in the Word editor

Example: Boilerplate reply that includes incoming text

Inserting hyperlinks

Inserting pictures

Working with Outlook signatures

Creating a signature

Inserting the default signature

Removing signature text

Chapter 18: Working with Recipients and Address Lists

Key recipient and address list objects

Understanding address lists

Displaying a contact folder as an address book

Example: Generate a report on Exchange users

Working with item recipients

Adding recipients

Example: Automatically add a Bcc recipient to an outgoing message

Understanding address resolution

Reading Recipient and AddressEntry information

Example: Create contacts for outgoing message recipients

Example: Respond to all the messages in a folder

Reading free/busy information

Showing the Select Names dialog

Example: Select contact links from a public folder

Chapter 19: Working with Attachments

Understanding Outlook attachments

Adding attachments to Outlook items

Viewing attachments in the user interface

Creating a “freedoc” in an Outlook folder

Working with attachments on existing items

Saving attachments to the file system

Example: Import embedded Outlook items

Example: Reply with attachments

Opening attachments

Working with hidden attachments

Chapter 20: Common Item Techniques

Using custom message forms

Controlling the settings for replies and forwards

Adding code to the Reply and Forward events

Working with voting buttons and other custom actions

Custom action properties

Writing code for custom action

Example: A vacation approval form

Using command buttons with custom actions

Sending a message with a specific account

Creating a meeting request

Assigning a task

Linking Outlook Items

Linking with a unique identifier

Understanding the Activities page

Using the Links collection

Example: Add a contact phone number to a task

Creating an annual event from a custom date field

Chapter 21: Deploying and Managing Outlook Forms

Understanding Outlook forms architecture

Understanding the forms cache

Launching a custom form

Managing Forms

Making a custom form the new global default

Converting existing items to use a custom form

Importing to a custom form

Managing custom fields

Deploying custom fields

Best practices for adding fields to custom forms

Deploying forms

Distributing forms to remote users

Publishing a custom form programmatically

Troubleshooting Outlook forms

Understanding one-off forms

Dealing with forms cache problems

Recovering a form from the forms cache

Chapter 22: Rules, Views, and Other Outlook Scripting Tasks

Why Outlook scripting is a challenge

Internal scripting with custom message forms

Deploying settings with a custom form

Using custom forms to generate reports

Working with Outlook Rules

Creating new rules

Running rules programmatically

Managing Folder Views

Setting view properties

Example: Create category-filtered views

Managing public folder views

Internal scripting with folder home pages

Chapter 23: Menus, Toolbars, and the Navigation Pane

Programming Outlook menus and toolbars

Working with submenus and other controls

Executing a toolbar command

Adding a new Explorer toolbar and controls

Sidebar: Where’s the Click event code?

Working with context menus

Example: Display a store’s data location

Example: Find related items

Working with the navigation pane and other Explorer panes

Showing and hiding panes

Working with navigation pane modules

Example: Show a favorite Contacts folder first

Chapter 24: Generating Reports on Outlook Data

Built-in report techniques

Printing from customized folder views

Copying data to Excel

Performing a Word mail merge

Coding reports with the Outlook object model

Sending output to Microsoft Excel

Understanding Excel report basics

Building a distribution list report

Formatting Outlook data for Excel

Sending output to Microsoft Word

Understanding Word report basics

Formatting Outlook data for Word

Using Word to build an invoice report

Building the invoice template

Coding the invoice report

Possible enhancements for the invoice report