Looking for:
– Microsoft Outlook Beginners Guide PDF Book | Free PDF Books

Working in the forms designer 4. Controls and the Control Toolbox 4. The Field Chooser 4. Getting forms design help 4. Saving forms and ending a design session 4. Understanding published forms 4. Creating your first custom contact form 4. Adding fields 4. Rearranging controls 4. Showing, hiding, and renaming pages 4. Setting control properties 4. Testing the form 4. Setting form properties 4. Saving and publishing the form 4. Using the form 4. Summary 5. Introducing Form Regions 5. Understanding form regions 5.
Controls for form regions 5. Creating your first form region 5. Registering and deploying form regions 5. Other form region manifest settings 5. Other considerations for deploying form regions 5. Limitations of form regions 5. Other ideas for form regions 5. Summary 6. Extending Form Design with Fields and Controls 6. Understanding fields versus controls 6.
Creating user-defined fields 6. Field types 6. Combination fields 6. Formula fields 6. Working with formula and combination fields 6. Adding and removing fields on Outlook forms 6. Binding a control to a field 6. Initial value 6. Simple validation 6. Validation formulas 6. Validation formula messages 6. Using form controls 6.
Text boxes 6. Command buttons 6. Check boxes 6. Option buttons 6. Frames 6. List box and combo box controls 6. Spin button 6. Multi-page control 6. Image control 6. Outlook View Control 6. Some control and field limitations 6. Laying out compose and read pages 6.
Summary III. Outlook Code Basics 7. Understanding when VBA code runs 7. VBA form events 7. What is a Sub anyway? Outlook VBA application-level events 7. Macros to run programs on demand 7.
Writing VBA code 7. Variables 7. Outlook properties and methods 7. Subroutines versus functions 7. Operators 7. Referring to VBA forms and controls 7. Writing VBScript code for Outlook forms 7. Declaring constants and variables 7. Custom form events 7. Adding VBScript code to an Outlook form 7. Canceling events 7. Referring to Outlook form controls 7.
Referring to Outlook item properties 7. Working with custom keywords properties 7. Creating custom properties programmatically 7. Writing other Outlook automation code 7. Starting an Outlook session 7. Limitations on Outlook automation 7. Summary 8. Code Grammar 8. Option Explicit 8.
Declaring variables and constants 8. Variable data types 8. Variable naming conventions 8. Understanding scope 8. Declaring constants 8. Writing procedures 8. Calling procedures 8. Passing arguments 8. Adding data types to parameters and functions 8.
Making code reusable 8. Documenting your procedures 8. More code style tips 8. Working with expressions and functions 8.
Elements of an expression 8. Using mathematical expressions 8. Working with strings 8. Extracting string parts 8. Comparing strings 8. Replacing parts of a string 8. Other useful string functions 8. Example: Parsing text from a structured text block 8. Working with dates and times 8. Basic date-related functions 8. Date extraction functions 8. Performing date arithmetic 8.
Time zones and international dates 8. Using arrays, dictionaries, and the Split and Join functions 8. Working with multidimensional arrays 8. Building and using dictionaries 8. Example: Parsing structured text with an array and a dictionary 8. Controlling program flow 8. Then statements 8. Select Case statements 8. Do loops 8. Next loops 8. Example: Handling multiselect list boxes 8. For Each Next loops for collections 8.
GoTo statements 8. Providing feedback 8. Feedback with message boxes 8. Feedback with VBA forms 8. Getting user input 8.
Using message boxes 8. Using input boxes 8. Using VBA forms 8. Working with files and other objects 8. Adding programming library references in VBA 8. Using the Scripting Runtime library 8. Using Windows Script Host techniques 8. Summary 9. Handling Errors, Testing, and Debugging 9. Understanding errors 9. Simple syntax errors 9.
Compile errors 9. Runtime errors 9. Logic errors 9. Outlook bugs 9. Testing and debugging in VBA 9. Using breakpoints 9. Working in break mode 9. Using the Immediate window 9. Continuing program execution 9. Adding VBA error handlers 9. Debugging Outlook form VBScript code 9.
Error handling in VBScript 9. Using the script debugger 9. Summary IV. Fundamental Outlook Coding Techniques Outlook Programming Basics Introducing the Outlook object model 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 Summary Application object events Using the ItemSend event 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 Application.
NewMailEx Using Items. ItemAdd Using the Application. Reminder and Reminders events Example: Processing messages and running other code on a schedule 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 Handling Click events from unbound controls Example: Using option buttons to change a caption color 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 event Storing and restoring control state Handling state in a folder-based workflow Working with Stores, Explorers, and Folders Information store concepts Information store techniques Adding a Personal Folders.
Removing a. Renaming a. 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 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 versus UserProperties PropertyAccessor limitations and errors This customization can be accomplished by writing an Outlook add-in with an event handler that gets called when Outlook saves an item, a built-in or custom property is changed, a file gets attached, or an e-mail is sent.
This rich event model allows Outlook solutions to extend built-in actions and perform additional data validation. Another option is to customize built-in actions or introduce new custom actions as part of introducing a form region to render a custom item type.
If the solution intends to introduce its own item type and control the business logic associated with the item, you should consider basing the custom item on a Post item. Custom properties can be added to this custom Post item using the UserProperties object, and your add-in can control custom property business logic by implementing event handlers hooked up to item or form control change events.
Outlook Explorer Window The Outlook Explorer window shown in Figure is the main Outlook application window and displays folder contents. A word of caution is in order before discussing the Explorer window. Although Outlook offers the ability to extend its UI, you should consider that the surface area for customization is limited in the Explorer window. If each one of them introduces a new top-level menu and toolbar for the Outlook Explorer, the UI will become busy to a point that Outlook usability as a whole suffers.
Instead of introducing a new menu or toolbar, consider merging custom commands with existing menus. Add-in preferences can be exposed under an additional tab in the Outlook Tools Options dialog box. Another solution is to make the functionality available only when the user actually needs it. In short, your UI should be context-sensitive. If an Outlook solution has its own store, then a custom UI can be available when the user works in this store and be hidden otherwise.
Introducing a fifth vertical pane is not desirable unless you locate a custom task pane in a horizontal location at the bottom of the Explorer window. To avoid user confusion, add-ins should not automatically hide or collapse panes without user interaction. Command Bars The menu bar, standard, and advanced toolbars that appear at the top of the Outlook Explorer window are built using Office command bars. Add-ins can introduce a custom toolbar or add, remove, or hide commands in built-in menu bars and toolbars.
Command bars are an Office extensibility mechanism shared by different Office applications. Additionally, the Navigation Pane displays a list of folders for each module. The object model includes support for switching modules, controlling which modules are displayed, and modifying the grouping of folders in modules that have folder groups.
The Outlook platform does not allow you to add a new module to the Navigation Pane. Figure Outlook Navigation Pane. View Pane The View Pane shown in Figure typically renders the contents of a folder with a view optimized for the item types stored in the folder.
For example, mail items are displayed in a table view, meetings and appointments in a calendar view, and contacts as business cards. The Outlook object model allows fully dynamic view customization in the View Pane. You can add or modify folder views programmatically. View fields can be added or removed, Group By fields can be added or removed, a filter can be applied, and almost all aspects of the view can be customized programmatically. Reading Pane The Reading Pane shown in Figure displays the currently selected item or attachment.
Outlook provides the ability to customize the look of the Reading Pane for both items and attachments. Form regions can be used to extend or replace how an item is rendered in the Reading Pane. A custom preview handler also can be registered to control the way an attachment is previewed in the Reading Pane. Items are added to the To-Do Bar by creating a new task item or by flagging mail or contact items for follow-up. Figure Outlook To-Do Bar.
Chapter 2 Outlook as a Platform 35 Context Menus The Explorer window contains a number of context menus that can be customized. The Navigation Pane offers the store and folder context menus, the View Pane offers the items and views context menus, the Reading Pane offers the attachment context menu, and the To-Do Bar also supports the item context menu.
Property Pages Configuration options for your solution can be integrated into the Outlook Tools Options dialog box by using a property page similar to the one shown in Figure Property pages can also be used to extend the Folder Properties dialog box. Figure Unified Messaging property page in the Tools Options dialog box. Outlook Inspector Window New to Outlook , form regions are the centerpiece for customizing the Inspector window and the Reading Pane.
Form regions allow for an additive UI by introducing an adjoining form region that shows up on the bottom of the first tab of a custom or built-in Outlook Inspector window.
Figure illustrates an adjoining form region on an Outlook Inspector window. Separate regions provide more control. They can be either added to or replace one or all of the tabs of an existing form. If, for example, a Contact form needs to be completely customized, the add-in can introduce a new form region that is used whenever an IPM.
MyCustomer item is displayed. The add-in can also register IPM. MyCustomer as the default form used when a user creates a new Contact in the MyCustomer folder. All controls support data binding to built-in or custom properties. Unlike controls in previous versions of Outlook, both the control hosting surface and the controls placed on that surface use Windows themes.
Figure The Outlook Inspector Window with adjoining form region. Although not an immediate component of the Outlook platform, Ribbon extensibility known as RibbonX allows you to add custom groups and commands to the Ribbon for a given Inspector type.
Figure illustrates a custom group added to the Ribbon on the Inspector for an appointment item. You can also repurpose built-in commands, hide built-in groups and commands, and insert your custom commands into built-in groups. RibbonX offers a superior control palette to Office command bars. You can leverage new picture galleries in your solution or utilize a host of controls that had no equivalent in the Office command bars object model.
Figure Prepare for Meeting sample add-in customizes the Ribbon for an Outlook appointment item. Custom task panes provide another customization option for the Outlook Inspector window. Whereas form regions target the extension and customization of the Outlook Inspector itself by typically displaying new user properties, custom task panes facilitate bringing related data Chapter 2 Outlook as a Platform 37 into Outlook just like a built-in task pane such as the Research Pane. Figure shows the Prepare for Meeting custom task pane in an Appointment Inspector window.
Figure Custom task pane in an Appointment Inspector window. Shoe Size and Customer ID are two additional properties that need to be tracked for each customer. The add-in would introduce an adjoining form region for Contacts containing these two properties and store the data as user properties in the backing Contact item.
The add-in would rely on the Outlook built-in Contact Inspector to render the rest of the form. RibbonX would be used to add a new verb to the Ribbon, allowing the user to check store inventory for shoes in a corresponding size and then show the results in a custom task pane docked to the Outlook Contact Inspector.
The Views object model would be used to create a new custom List View for the Customer Contact folder including these two new properties. The add-in could also introduce a custom toolbar that shows up when this Customer Contact folder is selected and allows the store clerk to restrict the Customer list and only display customers with a specified shoe size.
Although not strictly a component of the Outlook platform, InfoPath e-mail forms do provide a compelling way to collect survey data from messaging recipients.
This section helps you understand the purpose and design of InfoPath forms. Although there is no direct link between the Outlook object model and the InfoPath development environment, an InfoPath e-mail form uses aspects of the platform such as MessageClass and form-based rules that will help you understand the platform as a whole.
Microsoft Office InfoPath is a forms application that provides users with a way to gather structured information. Because InfoPath uses XML standards, data collected in InfoPath forms can be integrated directly into existing business processes such as databases, Web services, or workflows. Alternatively, collected data can be saved as individual files on collaborative sites such as a Microsoft Office SharePoint Server document library.
Integration with other Office applications, such as Outlook and Microsoft Office Excel , allows the forms experience to reach more users and provide easier data analysis. These forms can target data collection in an ad hoc manner, such as status reports and surveys, or be designed to integrate tightly with existing business processes and LOB applications using databases, Web services, and workflows.
Forms designed to target people, calendar, or task information are better suited to using Outlook forms. Such forms can add new capabilities on top of Outlook, such as a customer relations form, or can extend certain information on existing Outlook forms, such as adding an employee number to a contact item. An example of a common InfoPath form scenario is a weekly status report.
Although certain information in the form could be derived from Outlook, the majority of the information pertains to business processes. In this case, an InfoPath status report form can be published to all team members as an InfoPath e-mail form. Each team member completes and submits the form, which is submitted back to the manager. Alternatively, the status report could be part of an LOB application.
Subsequent workflow operations could send updated sales numbers, reports, and tasks to other members of the sales team. The InfoPath design environment allows form designers to drag and drop controls to quickly build the form. When a form designer creates a new InfoPath form, he or she actually creates what is known as a form template.
A form template defines the data structure, appearance, and behavior of the forms that users fill out. Think of a form template as a blueprint—the starting point that enables users to create new forms that use and store data in the same way. Because a form template must be available before you can fill out a form, form templates must be deployed to a location where users can access them.
Form templates are commonly deployed to locations on a company network, such as shared folders, Web servers, or libraries on Microsoft Windows SharePoint Services version 3 sites. Forms can also be deployed via installable packages.
If a user has permission to access the location where a form template is stored, he or she can fill out a form based on that template by using InfoPath, a Web browser, a mobile device, or Outlook Whether a form is filled out by using InfoPath or one of the other methods depends on several factors, including how a form template is designed and the technology available when the form is deployed.
For example, to fill out a form in Outlook , the form must be published to a list of e-mail recipients. If you receive an InfoPath e-mail form, you can reply to it, forward it, and store it just as you would with other items in Outlook InfoPath e-mail forms also allow added analysis features. By storing collections of related e-mail forms in InfoPath Forms folders in Outlook , you can organize and review data easily. For example, if you collect status report forms from your team, you can store the completed forms in an InfoPath Forms folder.
Besides keeping all related forms in one place, you can also choose to show data from each form in columns in a custom view for that folder thanks to Outlook read-only promotion of a subset of XML properties for InfoPath forms.
This allows for quickly grouping, filtering, and sorting data from multiple forms. Outlook defers rendering, editing, and actions for example, responding to these forms to InfoPath. Because InfoPath is built on XML standards, information can be quickly merged into a single InfoPath form or exported for more detailed analysis in Excel.
One goal for the Outlook platform enhancements was to unify these APIs all under the Outlook object model. This unification means that now all applications built on top of the Outlook object model will go through the very same business logic that Outlook relies on internally for its Personal Information Management PIM data types. Outlook Object Model The object model constitutes the heart of the Outlook platform. The goal for the Outlook platform enhancements is to enable developers to build rich solutions by relying on the Outlook object model.
The following areas provide the pillars of the Outlook platform. As part of the unification, many events were added to the Outlook object model to accomplish parity with ECEs. Unification means that the Outlook object model will be the sole API developers will rely on when writing a tightly integrated Outlook solution.
Solution developers are no longer shut out by entry barriers caused by fragmented APIs. Unification reduces the cost of writing Outlook solutions because developers have to familiarize themselves with only one API. These APIs are primarily supported to ensure compatibility with existing solutions. Application compatibility represents another important goal. The Outlook object model is compatible with previous Outlook versions; newly added functionality enhances the object model without removing or altering existing objects or methods.
Performance Performance is another critical attribute for writing successful Outlook integrations. Our customers spend much time in Outlook and expect it to remain responsive at all times.
The new Table object provides lightweight read-only row items for performant enumeration, sort, and search of Outlook data. Enumerating items with the Table object is approximately an order of magnitude faster than the enumeration of the Items collection without calling the SetColumns method. The Outlook object model also allows developers to leverage the Outlook integrated Instant Search infrastructure by using the content indexer for prefix and substring matching for searching Outlook items and attachments.
Security and Trustworthiness Outlook has improved the object model guard that warns the user when a program attempts to send e-mail messages or get address book information, making it easier for Outlook developers to write solutions that do not trigger Outlook security warnings.
At the same time, Outlook remains secure and trustworthy out of the box and allows administrators control over which solutions should run in the enterprise.
IT administrators can define security preferences through the existing Outlook security form stored in Exchange Public Folders or using Windows Group Policies. Group Policy administration of Outlook security settings is new to Outlook The chapters in this book provide detailed information and sample code on using the objects that represent these features in your solution.
Form Regions Outlook solutions can rely on Outlook custom forms with form pages or the new Outlook form regions to customize the forms associated with Outlook. The new separate and adjoining form regions in Outlook provide an additive or replacement UI to custom and built-in forms. One item type can support multiple adjoining form regions from different add-ins.
Form regions are no longer deployed through the Exchange Public Folder organizational forms library. The form and add-in make up an Outlook solution that is installed and updated at the same time. Form regions are based on earlier Outlook forms technology.
You design form regions in the Outlook Forms Designer shown in Figure Figure Designing form regions in the Outlook Forms Designer. Form regions can provide an additional UI to built-in forms or completely customize the forms area, which involves the introduction of a custom item type with a customized message class such as IPM.
Chapter 2 Outlook as a Platform 45 Download from Wow! An adjoining form region allows showing an additive UI on the bottom of the main tab of a built-in or custom form. An adjoining form region addresses this scenario. More than one adjoining form region is supported per form and each form region is expandable and collapsible. They enable lightweight extension of forms without having to redesign the entire form and also facilitate more than one solution extending the Outlook form.
MAPI was created to provide a standardized applicationlevel interface that allowed messaging components to communicate with widely incompatible messaging systems. MAPI differentiates between consumers client applications and producers access providers of messaging services.
Outlook does both; it is a rich application offering a consistent user experience across different back ends and also ships a number of MAPI providers enabling connectivity to a wide range of back-end servers. Writing managed MAPI code is not supported. What happened in the last decade since MAPI was introduced? For MAPI these items are simply mail items with extra properties.
MAPI does not know the meaning of these properties, nor is it aware of the business logic. Recurrence for an appointment item is a binary blob, and start time and end time are two individual properties not coupled with each other.
This means MAPI APIs are great for mail and address book functionality and to some degree for also reading other PIM items, but MAPI is largely not suitable to create or update them, as it would be up to the caller to be intimately familiar with item properties and business logic.
The recommendation is to use higher-level APIs like the Outlook object model to create or modify Outlook items. Using the object model ensures that the items are created in a consistent manner so that the proper side effects are triggered.
For example, when a meeting organizer changes the meeting time, an update needs to be sent to all attendees; simply changing the property would leave the meeting in an inconsistent state. MAPI does not specify the protocol used between client and server. Outlook has positioned itself as the premier offline client. One significant enhancement is cached Exchange built on top of a refined synchronization protocol when running against Exchange.
ISVs can benefit from these capabilities by also making their solutions work seamlessly whether the user is online or offline. A profile defines what stores, address books, and accounts, including preferences associated with them, should be loaded when Outlook is booted into this profile.
For example, the user can have a profile configured with Chapter 2 Outlook as a Platform 47 a business Exchange account and another profile with private POP and Hotmail accounts. MAPI profiles predate Windows user profiles. One scenario for which they were introduced was multiple users sharing the same computer, but with Windows supporting fast user switching this is no longer a driving factor. When multiple profiles are set up, Outlook is typically configured to prompt at boot to allow the user to select which profile Outlook should load.
Currently most users have only one single profile and add all the services they need to this single profile. A large percentage of Outlook users keep Outlook running throughout the entire day; closing Outlook and restarting the application is often too cumbersome to get to the mail sent to a different account. Solutions integrating with Outlook should be able to handle multiple profiles, but the majority of users run with only one profile. MAPI providers are registered in Mapisvc.
The user can configure these services for each Outlook profile. Administrators can also preconfigure Outlook profiles by creating and deploying Outlook profile file PRF files. Note Outlook no longer relies on Mapisvc. Additionally, other Outlook components such as views or rules are stored in hidden messages. Offline Folder files. The transport provides the ability to submit messages to Exchange Server. This provider also enables reading and writing messages to an Exchange store.
An alternative to a MAPI custom store provider is to cache the data in a. An example would be sending e-mail messages over a Web service or using a separate transport to communicate with a back-end service. Microsoft LiveMeeting uses a separate transport provider to communicate with LiveMeeting server. As mentioned earlier, EMSMDB implements both a transport and a message store, and as such is a dual tightly-coupled provider.
Only the custom MAPI transport provider knows how to transport this item and therefore gets to deliver the message. Recipients can be either single users or distribution lists. An Address Book provider introduces a new list of entries into the Address Book. This address list will also be searched during name resolution when a user clicks the Check Names button on the Ribbon or during automatic background name resolution. It shows the mobile number instead of the e-mail address for Outlook Contacts.
This provider is configured once the user adds an Outlook Mobile Service account to an Outlook profile. Writing such a provider is difficult, so alternatives should be considered.
If possible, rely on the built-in LDAP provider or, if the data set is relatively small, replicate data into an Outlook Contacts folder and rely on the Outlook Address Book provider.
The Replication API is worth looking at especially for data integration scenarios. Because these APIs offer deep Outlook integration, they have to be adjusted when the internal Outlook architecture evolves.
Fortunately, the transition from Outlook to Outlook involves very little work. The most powerful API documented in this reference, it allows. Extended MAPI completely supersedes the older version.
These simple APIs continue to offer applications an easy way to offer e-mail capabilities by integrating into the default e-mail program. This API is not recommended for further use. Although most of these components continue to be supported in Outlook , you should consider updating your code to use the new technologies introduced in this version of Outlook. If you are creating a new solution that only targets Outlook , use of these deprecated technologies is not recommended.
Collaboration Data Objects 1. Thanks to the unification effort for Outlook , all critical CDO functionality is now incorporated in the Outlook object model. Exchange Client Extensions As the name indicates, this extensibility technology was introduced for the Microsoft Exchange 4. Outlook, the successor of the Exchange client, later added support for ECEs.
Outlook added a large number of new events to the Outlook object model, enabling developers to phase out their code relying on ECEs. ECEs also enable the customization of command bars for Outlook items; these customizations manifest themselves on the Add-ins tab of the Ribbon.
Outlook Custom Forms with Form Pages Outlook continues to support Outlook custom forms with form pages, except for oneoff form definitions, which were deprecated for security and reliability reasons. In one-off forms, the form is embedded in the message and contains definitions for custom properties and VBScript.
One-off forms no longer run script and do not propagate custom properties to a recipient. A one-off form will render in a built-in form instead of the custom form definition stored in the form. Although Outlook custom forms with form pages continue to be supported in Outlook , solutions that target Outlook should use form regions in place of these legacy forms.
Outlook 97 also included the Exchange Forms Designer. This form development package has its own design environment based on bit Microsoft Visual Basic 4. Outlook has supported using these forms, but since Outlook you must download the necessary runtime files for these forms to work. Although they are considered obsolete, Outlook continues to support these forms if you have the runtime installed.
Electronic Forms Designer Microsoft Mail 3. These forms work in Outlook 97 through Outlook and have a dependency on the Microsoft Mail 3. Outlook and Outlook do not include this extension and therefore Electronic Forms Designer forms are not supported in Outlook and later versions. Development Tools The following section discusses development tools that you can use to create an Outlook solution.
The development tool that you select to create your solution depends in part on your scenario and also on the resources within your company. If you have a large number of developers who have moved from Microsoft Visual Basic 6.
NET, then Visual Basic will be a natural choice for your development tool. If you have trained C developers, then C would be your preference. Although the sample code in this book has been written using C , the code is also provided online in Visual Basic versions. The Microsoft Visual Basic. NET version of the sample code is not listed directly in the book because of space considerations rather than as a matter of preference.
Visual Basic. NET sample code is available on the Web site for this book. Although Outlook VBA can be used to create personal productivity macros, it is not suitable for the development and deployment of a professional solution. Only one Outlook VBA project can be deployed in a given user profile on a machine. This architecture means that only one VBAProject. If another solution overwrites the VBAProject.
Only command bars can be customized in Outlook VBA. Due to scheduling considerations, VSTO is not used for the sample add-ins in this book.
The CLR offers type safety, memory management and garbage collection, and a host of useful classes and features that are well documented in the extensive literature available on MSDN.
For an Outlook developer, AppDomain isolation prevents an addin from crashing due to an unhandled exception in another add-in. It also prevents an add-in from crashing other add-ins in a shared AppDomain.
If your team is trained in either Visual Basic. NET or C , they will be able to develop professional Outlook solutions using the guidance provided in this book. However, you might wonder if managed code is suitable for all Outlook solutions. The answer, of course, depends on your scenario. Although Outlook has targeted performance improvements over previous versions, you should understand that managed code requires the Outlook Primary Interop Assemblies PIAs to provide the Interop layer between.
This Interop layer does add a performance consideration to using managed code. Although this performance layer is not an obstacle for the vast majority 56 Part I Introducing Microsoft Office Outlook of Outlook solutions, it is a gating factor if your solution repeatedly enumerates large numbers of Outlook items, for example.
Remember that the Outlook object model operates on the foreground thread, so operations that poll the Outlook data store using the object model and the foreground thread can degrade the performance of Outlook as a whole.
The final decision is yours, and the choice of development tool is dictated first by your scenario, and second by your resources and budget. Managed add-ins use an Interop layer to connect to the Outlook host application, but they still use the basic COM add-in technology.
In Outlook , add-ins have achieved new prominence because an add-in is the only way that you can create Outlook form regions, Ribbon customizations for an Outlook Inspector, and Office custom task panes. Add-ins are also the preferred method for creating event listeners that implement the business logic of your solution. Your add-in can leverage the improved event model in Outlook to determine when an item is being saved or sent, an attachment is being added or removed from an item, an item is being deleted from a folder, or a custom or built-in item property is being changed.
And those are just a few of the event listeners that are possible in Outlook. The core architecture involved in creating a COM add-in has not changed in terms of how the Office application communicates with COM add-ins. Office continues to use the same architecture that was first implemented in Office Overall, unless there is a specific reason that dictates otherwise, COM add-ins are the recommended way for developers to create a custom solution that integrates with Outlook.
Deployment can occur through a standard Windows installer. In Outlook , all add-ins are trusted by default from the perspective of the Outlook object model guard.
In locked- Chapter 2 Outlook as a Platform 57 down environments, IT administrators can use the Outlook security form in Exchange public folders or use group policy objects to control a list of trusted add-ins.
In this way, any functionality that would typically generate a security prompt can be done from within the add-in. Outlook also provides the ability to turn off security prompts when antivirus software is installed and current.
This ability can also be controlled via group policy. However, due to the many object model improvements in Outlook , the COM add-in architecture is even more viable for many developers.
There are some scenarios where an add-in is not recommended for an Outlook solution. Exchange offers Web services for use in a Web application.
Summary This chapter has taken you on a tour of the Outlook platform. In brief, this chapter has described the pillars of the Outlook platform enhancements. During this discussion, prescriptive guidance has been provided to offer suggestions about how to build solutions on top of Outlook. Unlike the C sample code in the rest of this book, this code focuses on Visual Basic development experience.
Although the steps you need to follow in Visual Basic are not that different from the steps required for Visual C , it will be helpful to the Visual Basic developer to cover all the steps in detail necessary to create, build, and deploy an Outlook add-in.
If you are interested in obtaining practical results in a very short time, this chapter is for you. Microsoft Visual Studio continues to provide built-in support for developing Office addins through the Shared add-in template, but this template is missing some key blocks of code that are useful for writing Outlook COM add-ins in managed code. You can easily adapt the code in this chapter to work with VSTO.
The search results are displayed in a separate Explorer window, shown in Figure Figure Results from Instant Search are shown in a separate Explorer window.
Install the Outlook Add-in Templates To get you started writing Outlook add-ins, templates for both Visual Basic and Visual C are provided on the Web site that contains the sample code for this book. Double-click OutlookAddinTemplates. Click Next to confirm that you wish to start the installation. If you are installing the templates on Microsoft Windows Vista, you will see the User Account Control dialog box after installation begins.
Click Allow to indicate that you trust the setup package for the Outlook Add-in templates. After the installation has completed, click Close to dismiss the Setup Wizard dialog box. To create a Visual Studio add-in project using the add-in template, follow these steps: 1. In the Project Types list, click the Visual Basic node. Writing Code The next step in completing the Instant Search add-in is to write code in the project. Before you start to write code, you should understand that the template is a generic project aimed at typical Outlook add-in scenarios.
The template creates code that allows you to track multiple instances of Inspector or Explorer windows. At this point, you should follow this procedure to remove the code in these methods: 1. Comment out all the code in the InitializeAddin method. Comment out all the code in the ShutdownAddin method. The InitializeAddin Method The InitializeAddin method runs when your add-in is loaded by the host application, which in this case is Outlook If you were to examine the Connect.
Without getting into too many details about the IDTExtensibility2 interface, InitializeAddin is called when the add-in is loaded by the host application at boot time or when the add-in is loaded through a user action such as connecting the add-in manually via the COM Add-Ins dialog box. You use InitializeAddin and ShutdownAddin to create and destroy class-level instance variables that are required for your add-in and to wire up event handlers required by your solution.
Note To examine Connect. However, it is strongly recommended that you navigate to the top of the Connect class and type Option Strict On. Option Strict On involves more work on your part because you must cast Outlook members that return a type of Object to the correct type. Because Option Strict On provides strong typing, prevents unintended type conversions with data loss, disallows late binding, and improves performance, you should add this directive to the Connect class.
Adding Instance Variables The next step is to create class-level instance variables in the Connect class to represent command bar controls on the context menu for an item. Context menus in Outlook use the familiar Office command bars object model that has been present in several versions of Office. Context menu commands do not use the new Ribbon extensibility model. To add instance variables to the Connect class, follow these steps: 1. Double-click Connect. Locate the instance variables region shown in Figure in Connect.
Figure Class-level instance variables in the Connect class. Selection Hooking Up Events in Visual Basic If you use the WithEvents keyword when you declare an event-aware instance variable, Visual Studio does all the work for you to hook up the event. Because the Application instance variable that represents the Outlook. Application object has been declared WithEvents in Connect.
All you have to do is select the event and then write code in the event handler. ItemContextMenuDisplay Event The ItemContextMenuDisplay event occurs before a context menu for either a single highlighted Outlook item or for one or more selected Outlook items is to be displayed, allowing the CommandBar object representing the context menu to be customized by an add-in. For the Instant Search add-in, the Instant Search pop-up on the context menu is displayed only when a single mail item is selected.
When more than one mail item is selected or when the single selected item is not a mail item, the Instant Search pop-up on the context menu does not appear.
Application object in the Connect class is declared using WithEvents, the Application variable appears in the left drop-down list of the Code Editor for the Connect class. When you select the Application object in the left drop-down list and then select the correct event name in the right drop-down list, the event procedure is stubbed out for you. To write code for the ItemContextMenuDisplay event, follow these steps: 1. In the Connect class Code Editor, select the Application object in the left drop-down list.
Select the ItemContextMenuDisplay event in the right drop-down list. NET 69 If Selection. Item 1 If oItem. Add Office. CommandBarButton ctlThisWeek. CommandBarButton ctlThisMonth. CommandBarButton ctlLastWeek. CommandBarButton ctlLastMonth.
CommandBarButton ctlAllMessages. WriteLine ex. If Selection. Count is zero, then the code exits from the event procedure and no command bar pop-up is created. The OutlookItem class uses reflection to determine the common properties of an Outlook item and allows you to determine the underlying type of the item Object. Count is one and the item returned by the indexer of the Selection object represents a MailItem and the IsInstantSearchEnabled property returns True on the Store object that contains the item, then the Office CommandBar object model is used to create a pop-up menu represented by the instance variable ctlInstantSearch.
CommandBarPopup object. To add the pop-up menu to the item context menu, you call the Add method on the CommandBar object passed in the ItemContextMenuDisplay event.
Once the pop-up menu has been added, you then set the Caption and Tag properties for ctlInstantSearch. ContextMenuClose Event The ContextMenuClose event occurs just after a context menu is closed so that add-ins can dispose of any object references that have been obtained from other context menu events such as ItemContextMenuDisplay.
To write code for the ContextMenuClose event, follow these steps: 1. Select the ContextMenuClose event in the right drop-down list. Folder Represents the Folder object that contains the item on which the context menu is being displayed. If False, hides the To-Do Bar. To write code for the DisplayInstantSearchExplorer method, follow these steps: 1. Search to automate Instant Search exp. Display exp. ShowPane Outlook.
When the user clicks any one of the submenu items, the Click event for the Office. CommandBarButton is called. The code in the Click event simply calls the DisplayInstantSearchFolder method with the correct parameters to display an Explorer window that shows the results of the search. To write code for submenu Click events, follow these steps: 1.
Select the Click event in the right drop-down list. Click If LastSelection. Item 1 , Outlook. Parent, Outlook. To build the Instant Search add-in project, follow these steps: 1. Ensure that there are no errors in your code. If there are errors, Visual Studio will suggest how you should correct them. Application domain isolation means that an exception in another add-in will not cause your add-in to crash or operate in an unexpected manner.
Similarly, if your add-in encounters an unhandled exception, it will not cause all other managed add-ins running in the Outlook process to crash. When Outlook loads add-ins, an add-in that causes an error during boot can be placed on a disabled add-in list. Because Outlook cannot distinguish between one shared add-in and another, Outlook places Mscoree. With application domain isolation, disabling one add-in does not disable all other managed add-ins. Application domain isolation prevents an unhandled exception in one add-in from crashing all other add-ins in the same application domain.
Unexpected behavior can occur when addins share the same application domain. For example, if add-in A calls ReleaseCOMObject and FinalReleaseCOMObject on an object that it shares with add-in B and both add-ins are in the same application domain, add-in B encounters an access violation when it attempts to access the shared object. If an Exchange administrator uses the Outlook security form in an Exchange public folder or group policy to maintain a list of trusted add-ins, trusting a shared add-in means trusting Mscoree.
A COM shim acts as a native proxy for your managed add-in. Download the file by clicking the Download link on the Web site that accompanies this book and saving the file to your hard disk. Expand the Other Languages node in the Project Types list. Click the ellipsis … to specify the location of the managed assembly for your add-in. A Security Warning dialog box appears to indicate that you should strong-name your add-in dynamic link library DLL.
In this case, you do not provide a strong-name key for the add-in. In the Security Warning dialog box, click Yes. Click Next to display the Summary wizard page shown in Figure From the Project menu, select Properties. In the Output Directory combo box, type..
Creating a Setup Project The next step is to add a setup project to your solution. Once you have a setup project, you will be able to deploy the add-in to other users. Of course, you can modify this add-in to suit your own requirements. To create a Visual Studio setup project, follow these steps: 1. Press F4 to open the Properties dialog box shown in Figure Adding a project output to the setup project installs these DLLs to the Application folder created by the setup project.
To add primary outputs to the setup project, follow these steps: 1. Figure Add Project Output Group dialog box. To build the setup project, follow these steps: 1. Installing the Instant Search Add-In Assuming that the solution built successfully, you can now install the Instant Search add-in using the built setup project. To install the setup project, follow these steps: 1.
Click Close when the setup process is complete. When you select a command on the Instant Search pop-up menu such as Received This Week, you should see a new Explorer window that displays all messages received from the sender during this week. When you close Outlook, the Instant Search add-in should not cause Outlook to remain in memory.
Troubleshooting If you do not see the Instant Search pop-up menu, check to ensure that the Instant Search addin is installed. If the add-in is not installed, then you need to re-examine the steps to ensure that you did not miss a critical step. To determine if the Instant Search add-in is installed correctly, follow these steps: 1. In the left pane of the Trust Center dialog box, click Add-Ins.
What should you do when confronted with the real-world experience of writing your add-in from scratch? Although you should follow the same steps overall that are described in this chapter, when you are coding the add-in project you will run the add-in project in Debug mode.
To run the add-in in Debug mode, you must set the start action for your add-in in the add-in project. To set the start action for your add-in, follow these steps: 1.
In the Properties dialog box, click the Debug tab. Click the ellipsis … to open the Select File dialog box. In the Office12 folder, select Outlook. Debugging Code Before you attempt to debug your add-in, you should shut down Outlook. If Outlook is running, your debug session might not yield the expected results.
If Outlook is not running, you will not see Outlook. To ensure that Outlook is not running before you start debugging, follow these steps: 1. In the Windows Security dialog box, click Task Manager. In the Windows Task Manager dialog box, click the Processes tab. Ensure that Outlook. One interesting way to ensure that Outlook has shut down cleanly is to use the Mail application in Control Panel to force Outlook to boot with a profile prompt.
If the profile prompt appears when you start Outlook in Debug mode, you can be assured that no previous instance of Outlook was running when you started your debug session. When you have completed debugging, you can remove the profile prompt by using the Mail application again.
NET 85 Once you have your add-in project set up to perform debugging, you can use the great debugging features of Visual Studio These features include debugging tools such as setting breakpoints, using watch and locals windows, and using edit and continue. Be aware that when you hit a breakpoint in your code, you might cause Outlook to become unresponsive until you continue execution.
To debug your add-in, follow these steps: 1. Ensure that Outlook is shut down. Set your breakpoints before you begin the debugging process. Press F5 to launch Outlook and begin the debugging process. Outlook closes when you stop the debugging process. Summary This chapter has provided you with end-to-end instructions on how to build an Outlook addin using Visual Studio The add-in you have created leverages the new Instant Search feature of Outlook To ensure add-in stability, the Instant Search add-in is provided with its own application domain by way of a COM shim.
Finally, you also created a setup project so that you can deploy the add-in to other users. Happy coding! Click Allow to indicate that you trust the setup package for the Outlook Add-in Templates. After installation has completed, click Close to dismiss the Setup Wizard dialog box. In the Project Types list, click the Visual C node. At this point, you should follow the next procedure to remove the code in these methods. To remove the code in the InitializeAddin and ShutdownAddin methods, follow these steps: 1.
InitializeAddin Method The InitializeAddin method runs when your add-in is loaded by the host application, which in this case is Outlook You use InitializeAddin and ShutdownAddin to create and destroy class-level instance variables that are required for your add-in, and to wire up event handlers required by your solution.
You remove those event handlers in the ShutdownAddin event. Context menus in Outlook use the familiar Office command bars object model that has been included in several versions of Office. In the Solution Explorer, double-click Connect. Selection LastSelection; C Each event has a corresponding event handler method that is called when the event fires.
ItemContextMenuDisplay Event The ItemContextMenuDisplay event occurs before a context menu is to be displayed for either a single highlighted Outlook item or for one or more selected Outlook items, allowing the CommandBar object representing the context menu to be customized by an add-in. Remember that you just commented out the existing code in this method. Type Application and then press the period key.
In the Intellisense window, use your mouse or the keyboard to scroll to the ItemContextMenuDisplay event. Visual C will offer to hook up the event for you. At this point, press the Tab key. Press the Tab key again to insert the event delegate. In the Intellisense window, use your mouse or the keyboard to scroll to the ContextMenuClose event. Press the Enter key to select the ContextMenuClose event. At this point, you should see the following lines of code to hook up the event handlers: C Remove the line that Visual Studio inserted into the event handler: throw new Exception “The method or operation is not implemented.
CommandBar CommandBar, Microsoft. CommandBarPopup CommandBar. FindControl Type. Missing, Type. Missing ; ctlInstantSearch. CommandBarButton ctlInstantSearch. Missing ; 95 C Missing ; ctlThisMonth.
Missing ; ctlLastWeek. Missing ; ctlLastMonth. Missing ; ctlAllMessages. The Selection collection, like other collection objects in the Outlook object model, is one-based and the indexer for the Selection object returns a type Object.
In the case of the Instant Search add-in, the LastSelection object is set to null. Remove the line that Visual Studio inserted into the event handler: C Remember that you previously commented out the existing code in this method.
Type the following code into the ShutdownAddin method: Application. If false, hides the To-Do Bar. Add Folder, Outlook. Search InstantSearch , Outlook. Display ; exp. To write code for submenu Click events, follow these steps. SenderName; Outlook. Folder oMail.
If there are errors, Visual Studio will suggest how you should correct the errors. For example, if add-in A calls ReleaseCOMObject or FinalReleaseCOMObject on an object that it shares with add-in B and both add-ins are in the same application domain, add-in B encounters an access violation when it attempts to access the shared object.
In the Project Types list, expand the Other Languages node. A Security Warning dialog box appears to indicate that you should strong-name your add-in dynamic-link library DLL. Press F4 to open the Properties dialog box, shown in Figure Finally, you need to add project outputs to the setup project. Figure Add Project Output dialog box. When the setup process is complete, click Close. If the add-in is not installed, you need to re-examine the steps to ensure that you did not miss a critical step.
In the left pane of the Trust Center dialog box, click Add-ins. The COM Add-ins dialog box should indicate that the add-in is installed and connected as shown in Figure Debugging Code Before you attempt to debug your add-in, you should shut down Outlook before you proceed.
Finally, you also have created a setup project so that you can deploy the add-in to other users. The MessageClass property on an item provides the distinction between a built-in and custom type. This chapter concentrates especially on the properties and methods that are new to Outlook Modules provide a way of conceptualizing the type of work that an Outlook user needs to perform.
For example, you navigate to the Mail module to send and respond to e-mail messages. If you need to work with contacts, you navigate to the Contacts module to display your contacts in views such as the Card or Electronic Business Card view. The trend in Outlook is to break down some of the fences between individual modules. You can also view upcoming appointments on the To-Do Bar, so the notion of item type being tied to module no longer applies in all cases.
Built-in item types are specialized for the functionality particular to each module. These builtin types also provide you with business logic that pertains to the specific type. For example, appointment items have a start and end time, and start time must always precede end time. Recurring appointments follow defined patterns of recurrence, but recurrence exceptions allow variations in the recurrence patterns. In this chapter, you learn how you can use built-in item types that lend themselves to the functionality that you want to expose in your solution.
Table lists all the objects that represent builtin and custom items in Outlook and the corresponding base message class. Note that an asterisk after the base message class for example, IPM.
Custom items cannot be derived from the base class representing the built-in item.
Programming applications for microsoft office outlook 2007 pdf free download –
Microsoft Outlook is the most widely used e-mail program and offers the most programmability. Sue Mosher introduces key concepts for programming Outlook using Visual Basic for Applications, custom Outlook forms, and external scripts, without the need for additional development tools. For those who manage Outlook installations, it demonstrates how to use new features in the Outlook programming model such as building scripts that can create rules and views and manage categories.
Power users will discover how to enhance Outlook with custom features, such as the ability to process incoming mail and extract key information. Aimed at the non-professional programmer, it also provides a quick guide to Outlook programming basics for pro developers who want to dive into Outlook integration.
Her company, Turtleflock LLC, helps organizations get the most out of Outlook and other Microsoft Office products, providing custom application development and other support. Sue has been recognized by Microsoft with a Most Valuable Professional award every year since We are always looking for ways to improve customer experience on Elsevier. We would like to ask you for a moment of your time to fill in a short questionnaire, at the end of your visit.
If you decide to participate, a new browser tab will open so you can complete the survey after you have completed your visit to this website. Thanks in advance for your time. About Elsevier. Set via JS. However, due to transit disruptions in some geographies, deliveries may be delayed.
View on ScienceDirect. Author: Sue Mosher. Paperback ISBN: Imprint: Digital Press. Published Date: 30th May Page Count: For regional delivery times, please check When will I receive my book? Sorry, this product is currently out of stock. Flexible – Read on multiple operating systems and devices. Easily read eBooks on smart phones, computers, or any eBook readers, including Kindle. Institutional Subscription.
Free Shipping Free global shipping No minimum order. Dozens of new programming objects detailed including views, rules, categories, searches No previous coding experience or additional development tools required Examples outline issues using real-world functionality. Systems and Network administrators, applications developers and power users. Powered by.
You are connected as. Connect with:. Thank you for posting a review! We value your input. Share your review so everyone else can enjoy it too. Your review was sent successfully and is now waiting for our team to publish it. Reviews 0. Updating Results. Be the first to write a review. If you wish to place a tax exempt order please contact us. Accept Decline.