Back to description
Outlook stores items such as mail, appointment, task, and contact items in tables in a hierarchically structured database... more
Outlook stores items such as mail, appointment, task, and contact items in tables in a hierarchically structured database. This is unlike the underlying document object model that most other Office applications use and requires a change of orientation for programmers experienced in programming applications, such as Word or Excel. For this reason, this chapter explains Outlook’s data model and introduces Outlook’s data storage and data presentation models.
In this chapter, you first open the Outlook VBA project and set it up for use in creating and running macros and prototype code. Using the Outlook VBA project is often the easiest way to quickly test and prototype your Outlook code. Next, you discover the concept of a NameSpace and how to access Outlook data in folders and in individual Outlook items. This is the basis of all Outlook data access and is a building block for all Outlook programming. You next see how Outlook stores its data and how to access that data. In Outlook 2007, you can now access data either with the traditional Folders and Items collections or with the new Stores collection and Table object. The new members of the Outlook object model are explained in Chapter 2. Finally, this chapter discusses Inspectorsthe windows that display items such as emails or appointments, as well as Explorersthe windows that display folders. Working with these collections is critical for any Outlook program that works with the Outlook display.
NameSpace
Folders
Items
Stores
Table
... less
This chapter explains the most important new collections, objects, methods, properties, and events in the Outlook object... more
This chapter explains the most important new collections, objects, methods, properties, and events in the Outlook object model. So many things were added to the Outlook object model in Outlook 2007 that the object model doubled its size, making it hard to select the most important new features.
At the end of the Outlook 2000 beta, the Outlook MVPs (Microsoft Most Valuable Professionals) involved in Outlook development wrote a whitepaper listing items they wanted added to the Outlook object model so that development could be done using only Outlook code, without dipping into other APIs. Thanks to the splendid work of the Outlook team at Microsoft, spearheaded by Randy Byrne and Ryan Gregg, we finally have almost everything we asked for so many years ago.
The selections for this chapter are the ones I consider the most important, based on many years as an Outlook developer. All new Outlook 2007 features are covered in this book even if they aren’t in this chapter:
The unified object model: The Outlook object model now has many of the properties and methods of other APIs (Application Programming Interfaces), such as CDO 1.21 (Collaboration Data Objects), making Outlook 2007 a complete development platform. For most programming tasks, Outlook programmers now don’t have to master additional APIs to perform basic Outlook programming functions. This chapter explains important new additions to the Outlook object model, such as the PropertyAccessor, Stores, and StorageItems, user interface objects, tables, and accounts. You also learn about the limitations and bugs in some of the new additions to the Outlook object model.
PropertyAccessor
StorageItems
Improving your performance: Another part of this chapter explains how to use tables to increase the often slow performance of Outlook in accessing filtered groups and collections of items. Using tables for such accesses instead of filtered or restricted Items collections can often yield an order of magnitude performance improvement.
Increased security: You learn how the Outlook object model security guard treats trusted and untrusted Outlook code and how to ensure that code in Outlook COM addins is trusted by Outlook.
DASL: You discover DASL syntax and why mastering this syntax is so important in Outlook 2007 programming. DASL is the search syntax (DAV Searching and Locating) used in WebDAV (Web Distributed Authoring and Versioning) and also for Exchange and Outlook access based on schemas defined by Microsoft. The more familiar JET syntax for accessing Outlook items is also explained and contrasted with using DASL syntax.
This chapter focuses on the... more
This chapter focuses on the Application and NameSpace objects. As you’ve already learned in Chapter 1, these objects are your entry point into Outlook programming and are used throughout your Outlook applications. To help you understand the Application object, this chapter introduces methods for instantiating globally available and trusted Application and NameSpace objects for COM addins programmed using languages such as VB.NET and C#, with Visual Studio 2005 and VSTO 2005 SE development platforms. You then learn about some of the new methods, properties, and events of the Application object. You discover how to program context menus, and you get to work with context menus in many of the examples in this book. To better understand the NameSpace object, this chapter introduces you to the new Categories collection and Category objects, Exchange information, and user interface dialogs.
Application
Categories
Category
Note
The version of VSTO used for Outlook 2007 development is VSTO 2005 SE. It is referred to as VSTO in this book.
In this chapter, you learn more about working with the Outlook VBA project, and how to use it to create macros and to prototype... more
In this chapter, you learn more about working with the Outlook VBA project, and how to use it to create macros and to prototype code destined for use in COM addins and standalone projects.
The code in this chapter uses the intrinsic ThisOutlookSession class module, custom classes, and VBA UserForms for user input and data display to create macros that you can run on demand as well as code that runs automatically when Outlook starts or in response to specific Outlook events. These types of uses are common not only for VBA macro code but also in almost every Outlook application you write, including COM addins and standalone projects.
ThisOutlookSession
UserForms
The forms Outlook uses to show open items can be customized by adding controls and code. You often use custom form applications... more
The forms Outlook uses to show open items can be customized by adding controls and code. You often use custom form applications for things such as Help Desk tickets, routing of approval or review forms, and human resources forms. These custom forms and form applications were the only way of providing a custom user interface for Outlook items until Outlook 2007. Form regions are a new way to customize an item’s user interface and provide opportunities for customization that aren’t available with standard custom forms.
No investment was made in new features for custom forms in Outlook 2007, and none has been made for many versions of Outlook. Microsoft is encouraging forms development for Outlook 2007 to concentrate on using form regions. Of course, this approach works only if every user is running Outlook 2007 and won’t work if the forms are used with earlier versions of Outlook.
In this chapter, you learn how to customize Outlook forms, and the advantages and disadvantages of using custom forms. You also learn about form regions and how to design and use them.
A complete discussion of Outlook custom forms is a big topic that can take up an entire book, so only the basics of custom forms are covered in this chapter. For more information about designing and working with custom forms and lots of information about various problems and solutions for custom forms, I recommend looking at the material at www.outlookcode.com/d/forms.htm.
www.outlookcode.com/d/forms.htm
In this chapter, you learn how to create Outlook COM addins, including property pages that are shown when the Tools>Options... more
In this chapter, you learn how to create Outlook COM addins, including property pages that are shown when the Tools>Options and folder Properties dialogs are displayed. COM addins are the preferred way to create and deploy Outlook customization code. A COM addin is the only way to work with such features as the Ribbon interface for Outlook Inspectors, code behind form regions and custom task panes. COM addin code is more robust than Outlook VBA or forms code, and problems with COM addin code can usually be isolated strictly to that addin. You will also learn how to communicate with a COM addin by using external code
The VB.NET and C# projects associated with this book are available for download in shared addin and VSTO 2005 SE formats for Outlook 2007–only code. Other templates are also available for download. The templates are available for download on the Wrox Web site (www.wrox.com) as well as on my Web site at www.slovaktech.com.
www.wrox.com
www.slovaktech.com
In this chapter, you learn how to use Outlook COM addins to work with the Outlook user interface. This includes using the... more
In this chapter, you learn how to use Outlook COM addins to work with the Outlook user interface. This includes using the CommandBar interface for Outlook Explorers for custom menus and toolbars, the Ribbon interface for Outlook Inspectors, Explorer and Inspector custom task panes, form regions, and custom Views. COM addins are required to work with the Ribbon and custom task panes, as well as to apply business logic to form regions.
CommandBar
Explorers
Inspectors
Explore
Inspector
These user interface techniques complete the Outlook addin templates that can be used as the foundation for all Outlook COM addin programming. As in the previous chapter, the code for the user interface portions of the addin templates are presented in VB.NET and C#, with variations for VSTO and shared addin templates. The templates are available for download from the Wrox Web site (www.wrox.com) as well as from my own Web site, www.slovaktech.com.
Deployment techniques for the addin templates are covered in Chapter 9.
In this chapter, you will learn how to interface Outlook with other applications such as Word, Excel, and Access. An Outlook... more
In this chapter, you will learn how to interface Outlook with other applications such as Word, Excel, and Access. An Outlook programming book can’t cover every application that can be interfaced with Outlook, the list includes any application that works with data and exposes an object model or can read or write data using any interface such as ADO or ADO.NET or an intermediate object such as a Web service. This chapter serves as an introduction to the topic of interfacing with other applications, a topic that merits a book of its own.
If the application you want to interface with has a macro recorder, such as Word or Excel, use the macro recorder to capture keystrokes for various actions and to create the VBA code that is the macro. This makes learning how to work with those object models easier than starting to write code from scratch.
The location used to save the templates, worksheets and databases used for the examples in this chapter is C:\Pro_Outlook. If you change the location where these files are stored, change the file paths in the code samples in this chapter to match where you saved the files. The code and templates for this chapter can be downloaded from the Wrox web site (www.wrox.com). The code files for the chapter are Chapter_8_Database.bas, Chapter_8_Excel.bas, Chapter_8_Word.bas, Chapter_8_IE.bas, and the modules for the Browser form BrowserForm.frm and BrowserForm.frx.
C:\Pro_Outlook
Chapter_8_Database.bas
Chapter_8_Excel.bas
Chapter_8_Word.bas
Chapter_8_IE.bas
BrowserForm.frm
BrowserForm.frx
The examples are written to run as Outlook macros in the Outlook VBA project and use the intrinsic Application object to refer to the Outlook.Application object. If the code is used in another context such as a COM add-in or standalone code use an instantiated Outlook.Application object instead of Application.
Outlook.Application
In this chapter, you learn about real-world Outlook programming and how to make the best use of Outlook code to support multiple... more
In this chapter, you learn about real-world Outlook programming and how to make the best use of Outlook code to support multiple versions of Outlook. You also learn about coding to work around known problems for Outlook developers, how to deploy managed code addins, and how to use different APIs, such as Redemption, to accomplish tasks that still can’t be accomplished using the Outlook object model. The tricks and tips presented in this chapter are things I’ve learned and discovered in my years of Outlook programming and should be helpful in your Outlook coding projects.
In this chapter you will learn how to use an Outlook COM addin to extend tasks to create a hierarchical task system. The... more
In this chapter you will learn how to use an Outlook COM addin to extend tasks to create a hierarchical task system. The Task Management System addin lets you add child tasks to an existing task, and uses a custom task pane to display related tasks in a treeview control.
Outlook tasks have always been isolated items, only suitable for use as a to-do list. A task can be linked to a contact but you can’t relate one task to another to provide for parent-child relationships, something necessary for use as a task manager. The Task Management System adds the basic essentials for a task manager and can be used as the basis for a more sophisticated set of task management features.
The code is provided as two addin projects, one in VB.NET and the other in C#. Both are specific to Outlook 2007, using the PropertyAccessor object and the Ribbon, which aren’t available in earlier versions of Outlook. Both projects require Visual Studio 2005 and Framework 2.0 or higher.
The projects are available for download from the Wrox web site (www.wrox.com) as well as from www.slovaktech.com. These projects also include setup projects configured to create debug installations. Shims used to provide unique application domains for shared addins are not provided for the projects.
Outlook 2007 introduces many new objects and collections to the Outlook object model, each with associated methods, properties... more
Outlook 2007 introduces many new objects and collections to the Outlook object model, each with associated methods, properties, and events. Many existing objects and collections are also enhanced with new methods, properties, and events. This appendix lists all new objects and collections in Outlook 2007, with their associated methods, properties, and events as well as methods, properties, and events added to previously existing objects and collections in the Outlook object model. These include:
The new Table objects in Outlook and the increased importance of DASL syntax in Outlook coding also require familiarity with the various DASL property tags for Outlook items, and many common DASL property tags are also listed in this appendix. DASL is the search syntax (DAV Searching and Locating) used in WEBDav (Web Distributed Authoring and Versioning) and also for Exchange and Outlook access based on schemas defined by Microsoft.
All new objects and collections in the Outlook 2007 object model, with their associated methods, properties, and events.
All new methods, properties and events added to objects that were available in previous versions of Outlook. Only the enhanced methods, properties, and events are listed in this section.
The most commonly used property tags for Message, Appointment, Contact, and Task items in Outlook.
There are many online resources for getting information about Outlook development, and for Outlook 2007. Microsoft has outdone... more
There are many online resources for getting information about Outlook development, and for Outlook 2007. Microsoft has outdone itself by providing articles, blogs, sample addins and other resource material. In addition to Microsoft resources, many Web sites have Outlook sample code and information about solving specific Outlook programming problems.
This appendix provides listings of many resources for Outlook developers, as well as information about online support forums and newsgroups that are invaluable for any Outlook developer. Also listed are resources for VSTO development and support, MAPI tools and SDKs (Software Development Kits) and useful developer tools such as virtual machines.
Microsoft often changes the URLs for its online resources, often without forwarding links being applied. The links listed here are accurate at the time this was written.
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they must be viewed using the Adobe Reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapter on Demand File Any Wrox Chapter on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions, you may contact Customer Care at (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday). If you have any issues related to Technical Support, please contact us at 800-762-2974 (United States only) or 317-572-3994 (International) 8 a.m. - 8 p.m. EST, Monday - Friday).
Related Books