Sample Tasks Using the Outlook 2007 PIA
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
This section contains code samples in Visual Basic and C# that demonstrate how to perform certain tasks in Outlook. To run these code samples, you must have installed , the Outlook 2007 Primary Interop Assembly (PIA), and Microsoft Visual Studio 2005.
Although the samples in this section do not assume that you have installed Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System Second Edition, the Visual Studio Tools for Office portal on MSDN includes some basic how-to tasks written in managed code. For information about these basic tasks, see Developing Outlook Applications. Code samples in this section range from the beginner to the intermediate levels and are adapted from the book Programming Applications for Microsoft Office Outlook 2007.
In This Section
The following code samples manage Outlook's built-in item types:
How to: Create a Mail Item Using a Message Template
This example shows how to create a mail item by using a message template.How to: Create a Contact Item from a vCard file and Save the Item in a Folder
This example imports all the vCard files in a file system folder and saves the contacts into a specified folder.How to: Create a Mail Item, Attach a Report, and Send the Mail Item to the User's Manager
This example creates a mail item, attaches an attachment to the item, specifies the user's manager as the recipient, and sends the mail item.How to: Send a Mail Item with an Electronic Business Card
This example creates a mail item, looks for an Electronic Business Card, and inserts it into the mail item if it finds one.How to: Create an Appointment that Starts in the Pacific Time Zone and Ends in the Eastern Time Zone
This example creates an appointment that begins in the Pacific Time Zone (GMT-8:00) and ends in the Eastern Time Zone (GMT-5:30).How to: Create a Recurrent Task
This example shows how to create a task that occurs at a regular interval.
The following code samples demonstrate how to work with different types of Outlook data:
How to: Add or Remove a Store a
This example shows how to add and remove a store in a specified profile.How to: Store Solution-Specific Data as a Hidden Message in a Folder
This example shows how to retrieve hidden data that is stored as a hidden message of a specific message class in a folder.How to: Share Free/Busy Schedule Within a Specified Period in a Calendar
This example obtains the free-busy schedule within a specified week from a calendar and displays the free, busy, and subject details to the user.How to: Ensure that Custom Item Properties are Supported in Folder-Level Queries
This example shows how to ensure that when you add a custom property to a type of item, you also add the property to the folder so that you can query on the property.How to: Filter and Efficiently Enumerate Items in a Folder
This example shows how to use the Table object to filter for items in the Inbox that have attachments, and efficiently enumerate such items, displaying selected properties for each item.
The following code samples work with Outlook's address books and recipients:
How to: Create a Meeting Request, Add Recipients, and Specify a Location
This example creates an appointment item as a meeting request, specifies the time, recipients, and location of the meeting, and displays the appointment in an inspector.How to: Display the Select Names Dialog Box to Resolve Recipients
This example attempts to resolve the specified recipients and displays the Outlook Select Names dialog box for each of the recipients that cannot be resolved.How to: Obtain the Address Book that Corresponds to a Contacts Folder
This example shows how to obtain the address book that corresponds to the default Contacts folder.How to: Obtain Availability Information for an Exchange User's Manager
This example displays the next time that a user's manager has a free 60-minute time slot in the manager's calendar.How to: Obtain Members of an Exchange Distribution List
This example lets the user select an Exchange distribution list from the Select Names dialog box, and expands the distribution list to display its members.
The following code samples show how to use various query languages to search Outlook data:
How to: Search for a Phrase in the Body of Items in a Folder
This example searches the Body of items in the Inbox and returns items that contain the search string "office".How to: Search Attachments of Items in a Folder for an Exact Phrase
This example searches the attachments of items in the Inbox and returns items that contain the exact search string "office".How to: Filter Recurring Appointments and Search for a String in the Subject
This example filters recurring appointments in a Calendar folder that falls within a date range, and searches in two ways for the string "office" in the subject.
The following code samples demonstrate sharing various information with other users:
How to: Share Calendar Information Through E-Mail
This example shows how to share information from a calendar by e-mail in the iCalendar format.How to: Save a Calendar to Disk
This example shows how to save an entire calendar to disk in the Calendaring and Scheduling (ICS) file format.How to: Open and Display the Contents of an iCalendar File
This example shows how to open and display the contents of an iCalendar file, depending on whether the file contains a single or recurrent appointment, or the file contains a group of appointments.