Programming MicrosoftВ® OutlookВ® and Microsoft Exchange 2003, Third Edition (Pro-Developer)
Outlook supports a variety of folder views, including custom views, to give you and your users flexibility in the presentation and organization of information. These views can be used in any type of Outlook folder. Outlook allows you to set the initial view for a folder, and it remembers the state of the view for each user . Outlook supports five types of views:
-
Table view The most commonly used Outlook view. The table view consists of rows and columns that display the information in the folder.
-
Timeline view Shows the chronological order of the items in the folder as icons.
-
Card view Shows the items in the folder as individual cards, similar to a business card file.
-
Day/Week/Month view Shows items arranged in a calendar. This view is best used for applications that have a date and time field as one of the application's primary fields.
-
Icon view Shows all items in the folder as individual icons on an invisible grid. The icon view is best used in folders in which displaying details of the items are not important.
Creating New Views
You can create new views in Outlook in two ways: by defining a new view in the Define Views dialog box or by adding the Current View box to your Outlook toolbar. The second option is the easiest and is the one you will probably use more often. To add the Current View box to your Outlook toolbar, follow these steps:
-
Right-click on the Outlook toolbar, and then choose Customize.
-
On the Commands tab, select Advanced from the Categories list.
-
In the Commands list, scroll down until you find the Current View drop-down list.
-
Drag and drop the Current View drop-down list onto your toolbar. Close the Customize window by clicking Close. You should see Outlook fill in the Current View drop-down list with the name of the current view of the folder. You can now use the Current View drop-down list to create new views by typing over the name in the box.
When you attempt to save your views, Outlook prompts you to indicate what type of view will be used. For example, if you type a new name for a view in the Current View drop-down list, Outlook will ask you how the view should be used. You can apply your views in Outlook in three primary ways:
-
This Folder, Visible To Everyone This option enables the view to be used on the current folder and to be visible to everyone. Any person with permission to open the folder can select this view from the drop-down list of current views. As a developer, you can create the views for your Outlook application and then save them so that all your users can use them.
-
This Folder, Visible Only To Me If you select this option, the view is for the current folder but is visible only to the current user. You can use this view to show specialized information (such as debugging information) to only certain users of your application.
-
All Folders This option enables the view to be used in all folders that have the same item type as the current folder. This allows you to share your favorite views across folders of the same type.
So far, our Document Library application is only a folder into which users can drag and drop documents to share with other users. By using views, we can transform our simple Document Library application into a more useful application for our users. The first view we'll create is an icon view so that our application looks more like a network file share than an Outlook folder. Adding this view will make navigating among the files in the folder easier for our users. To create the icon view for the Document Library application, follow these steps:
-
Select the Document Library folder in Outlook.
-
From the View menu, choose Arrange By, and then Current View, and then click Define Views.
-
Click the New button, and then type a name for your view, such as As Icon .
-
In the Type Of View list box, select Icon.
-
In the Can Be Used On area, select This Folder, Visible To Everyone.
-
Click OK. The Customize View: <View Name> dialog box will appear.
-
Click the Other Settings button, and then select the type of icon you want to use: Large Icon, Small Icon, or Icon List.
-
Click OK twice.
-
Click Apply View. You now have an icon view for our Document Library application. Your view should be similar to the one shown in Figure 3-16.
Figure 3-16: A Large Icon view of the information in the Document Library application
The second view we'll create is a timeline view. This view will enable our users to quickly see the last time a document was saved and how much time has elapsed between when the document was created and when it was last edited and saved. By implementing this feature, users can discard older versions of the document and ensure that they are using the most recent version. As you will see in Chapter 4, you can customize your views by using custom properties directly from Office documents.
To create the timeline view for the Document Library application, follow these steps:
-
Select the Document Library folder in Outlook.
-
From the View menu, choose Arrange By, and then Current View, and then click Define Views.
-
Click the New button, and then type a name for your view, such as Document Timeline .
-
In the Type Of View list box, select Timeline.
-
In the Can Be Used On area, select This Folder, Visible To Everyone.
-
Click OK. The Customize View: <View Name> dialog box will appear.
-
Click the Fields button to open the Date/Time Fields dialog box.
-
In the Available Date/Time Fields list, select the Created field as the starting time for the document in the view and then click the Start button.
-
In the Select Available Fields From drop-down list, select All Document Fields.
-
In the Available Date/Time Fields list, select Last Saved Time and then click the End button to make the time the document was last saved the ending time for the document in the view.
-
Click OK twice. Click Apply View. The view of your documents folder should be similar to Figure 3-17. Outlook automatically draws a line indicating the amount of time that has elapsed between the creation time and the time the document was last saved.
Figure 3-17: A timeline view of the Document Library application
Customizing the Current View
You can customize the current view by using the Field Chooser to drag and drop new columns. After you add a new column, the view is automatically updated. You can also add complex data types such as combination or formula fields to the view. Many people find customizing a view easier using the drag-and-drop capabilities of the Field Chooser than by selecting available columns from a drop-down list as in the Customize View dialog.
To add new columns to the Document Library view, follow these steps:
-
In the Document Library application, create a new table view and name it Document Properties .
-
Right-click on any column heading in the Document Properties view, and then choose Field Chooser.
-
Select All Document Fields from the drop-down list.
-
Drag and drop Author, Revision Number, and Last Saved Time from the Field Chooser to an area next to one of the columns in the view. (Outlook displays red arrows in the column header bar to indicate where the field will be inserted.)
-
To remove a column, select the column heading and then drag it off the column heading row.
Note You can remove columns from your view by dragging the columns until a large X appears. After you release the mouse button, the column disappears from the view.
Formatting the Columns in a View
Notice that when you drag and drop columns from the Field Chooser, by default Outlook gives the column heading the same name as the field on which the column is based. Also notice that Outlook applies default formatting for the columns. For example, Outlook formats the Last Saved Time column with the day, the date, the year, and the time the document was last saved. Most users won't need this much detail about the last-saved time for the document. To make views more intuitive for your users, Outlook allows you to change the name of the column heading without changing the name of the underlying field. You can also change the default format of values for a specific column in the view. For example, you can change the format of the Last Saved Time column heading so that it displays only the date the document was last saved rather than the date and the time, as you saw earlier. Note, however, that changing the format of the column does not modify the format of the field on which the column is based. To modify the format of the field, you must use the Field Chooser.
To change the format of a column in the Document Library application, follow these steps:
-
Right-click on the Last Saved Time column heading in the Document Properties view, and then choose Format Columns.
-
In the Format drop-down list, select the option that shows only the month, the day, and the year (such as April 07, 2003).
-
In the Label box, type Last Edit Time .
-
Click OK. Your date/time column should look similar to the one shown in Figure 3-18.
Figure 3-18: The new Document Properties view after we change the format and label of the date/time column
Grouping Items in a View
Grouping items in an Outlook view makes it easy for users to find items that are related . Outlook supports up to four levels of grouping in a single view. You can group items in a view in one of two ways:
-
Using the Group By box This method is the easiest because it allows you to use drag-and-drop functionality to select the column as the grouping. If you drag and drop more than one field into the Group By box, Outlook graphically draws the relationship between the fields as primary groups and subgroups.
-
Customizing the Current View option This method gives you a few more options when you set the grouping for a view, but it isn't as easy as using the Group By box.
To group items by Author using the Group By box, follow these steps:
-
Right-click on a column for the Document Library application, and then choose Group By box to display the Group By box above the column headings.
-
To remove the Date field, from the View menu choose Arrange By, and then Show In Groups. (Show In Groups is a toggle menu item. If a check mark is next to the menu item, it is on and will be turned off the next time you choose it.) Drag and drop the Author column into the Group By box, or drag items from the Field Chooser into the Group By box.
-
If you want to group by more than one field, drag and drop a second field into the Group By box. For our purposes, just drag the Category field from the Field Chooser in the All Document Properties section to the Group By box. Notice that Outlook draws a line from the Author field to the Category field to indicate that the view is grouped first by author and then by category. If you click on the field in the Group By box, you can also change the sorting of the field as part of the grouped view. Take a look at Figure 3-19.
Figure 3-19: The line connecting the Author field to the Category field -
Close the Group By box by right-clicking on a column heading and selecting Group By box.
To create the same grouping using the Current View option, follow these steps:
-
From the View menu, choose Arrange By, and then Current View, and then click Customize Current View.
-
Click the Group By button to display the Group By dialog box.
-
In the Select Available Fields From drop-down list, select All Documents Fields.
-
In the Group Items By area, select the Author field. You can also show the field in the view by selecting the Show Field In View option. If you drag and drop the field into the column headings, you will lose it from the Group By box.
-
In the Select Available Fields From drop-down list, select Frequently-Used Fields. In the first Then By area, select the Categories field. Figure 3-20 shows the completed Group By dialog box.
Figure 3-20: The Group By dialog box -
Click OK twice.
The only difference between the two methods we've used to create the same view is that in the Group By dialog box that appears when you choose Customize Current View from the menu, you can specify whether the groups are expanded or collapsed by default.
Sorting Items in a View
Outlook also supports sorting items in a view in either ascending or descending order. When you combine sorting with grouping, you get the best combination of features for making your information available to users in a view. For example, instead of just grouping our Document Library items by author, we can also sort the items so the most recently saved documents appear at the top of each grouping.
To create a sorted list, you can click on the column heading or use the Sort dialog box. To create a sorted view by using the Sort dialog box, follow these steps:
-
From the View menu, choose Arrange By, and then Current View, and then click Customize Current View.
-
Click the Sort button to display the Sort dialog box (shown in Figure 3-21). In the Select Available Fields From drop-down list, select the subset category of the fields from which you want to choose the sort criterion.
Figure 3-21: The Sort dialog box -
In the Sort Items By area, select the field you want to use as your sort criterion.
-
To select further sorting subsets , select the next field you want to sort by in the Then By area.
-
Click OK twice.
Filtering Information in Views
Filtering allows you to create views in which only certain items are visible to users. The criteria you set can be based on built-in Outlook fields or custom fields. Filters can be simple, with only one or two conditions, or they can be more complex, using multiple conditions or the advanced filtering features. When you set multiple conditions on a filter, Outlook ANDs them together. When you set multiple arguments in a single condition, Outlook ORs these arguments so that if only some meet the condition, the item appears in the view.
To create a simple filter for the Document Library application, follow these steps:
-
From the View menu, choose Arrange By, and then Current View, and then click Customize Current View.
-
Click the Filter button.
-
Click on the More Choices tab.
-
In the Categories box, type Outlook; Exchange , as shown in Figure 3-22.
Figure 3-22: The Categories filter for the Document Library application -
Click OK twice.
Here's how to create a complex filter for the Document Library application:
-
From the View menu, choose Arrange By, and then Current View, and then click Customize Current View.
-
Click the Filter button.
-
Click on the Advanced tab.
-
Click Field, point to All Document Fields, and then click the Last Saved Time field.
-
In the Condition drop-down list, select Last Month.
-
Click Add To List.
-
Click Field again, point to All Document Fields, and then click the Author field.
-
In the Condition drop-down list, select Is Not Empty. Click Add To List.
-
Click Field again, point to All Mail Fields, and then click the Message Class field.
-
In the Condition drop-down list, select Contains and type IPM.Document.Word.Document in the Value box. Click Add To List.
-
Click OK twice. You might find that you have no items in your folder after doing this. If you do not have documents with the Author field set, you will not meet the filter criteria.
Editing View Settings
You can customize the formatting of your views at a more detailed level by using the Other Settings dialog box. The type of view you create determines which settings are available for you to edit. For example, if you are editing a table view, you can set the font size , enable in- cell editing, enable autopreview, create gridlines, and enable the preview pane. If you are editing an icon view, you can set the view type (such as Large Icons, Small Icons, or Icon List), and you can specify whether Outlook should automatically arrange and sort the icons in your view.
|
The in-cell editing option for customizing a table view allows users to quickly add new items to a folder or change the properties of current items in the folder without opening a form. All of the changes to the item can be typed directly into the view. This capability helps speed up applications that require a lot of data entry, such as customer contact lists or surveys.
If you enable in-cell editing in a folder that contains Office documents, you cannot modify the properties of the documents directly in the view. These properties are read-only inside Outlook. You must modify these properties using the Office program that originally created the document.
|
Conditional Formatting
If your custom view is a table view, you can use the conditional formatting capabilities of Outlook. Conditional formatting lets you apply custom formatting to items that meet certain conditions. For example, you can set a condition in the Document Library application so that all Word documents appear in 12-point, red Arial font. Outlook automatically sets some default formats for the most common conditions, such as unread, expired , and overdue e-mail. You can customize the settings for these default conditions or create your own conditions.
To set conditional formatting, follow these steps:
-
From the View menu, choose Arrange By, and then Current View, and then click Customize Current View.
-
Click the Automatic Formatting button.
-
Click Add, and then type a name for the formatting rule in the Name box; for this example, type Word Documents .
-
Click the Font button, and then select 12-point Arial as the font and red as the font color . Click OK.
-
Click the Condition button. As you can see, the dialog box is the same as the Filter dialog box shown earlier in Figure 3-22.
-
Click on the Advanced tab.
-
Click Field, point to All Document Fields, and then click Author.
-
From the Condition drop-down list, select Is Empty.
-
Click Add To List.
-
Click Field, point to All Mail Fields, and click Message Class.
-
From the Condition drop-down list, select Contains.
-
In the Value text box type, IPM.Document.Word . Click Add To List.
-
Click OK two more times.
Limiting Views to Those Created for the Folder
Outlook provides several standard views in a folder by default. These views depend on the folder's default content type, and in many cases they are not relevant to your application, so you will not want them to appear in the Outlook view list. Outlook allows you to hide the default views and show only custom views created for the current folder by selecting the Only Show Views Created For This Folder option in the Define Views dialog box.
Implementing Threaded Views
You'll often want to display the information in a folder as a threaded view so users can see the history of responses to an item. These responses are indented in the view to make it easier to follow the flow of information specific to the item. In a folder based on e-mail items, Outlook provides a default view called By Conversation Topic, which provides this threading capability. But suppose you don't build your application using e-mail items, and you use task items instead. To create threaded views in a folder such as this, Outlook supports two unique properties, called Conversation and Conversation Index.
|
If you use OWA as one of the clients for your application, the Only Show Views Created For This Folder property will not disable the default views in OWA. To disable the default views in OWA, you must customize the Active Server Pages of OWA for Exchange 5.5 to hide the default views for your folder. Any custom table views that you create in the Outlook client will automatically be available to the OWA client as long as the Automatically Generate Microsoft Exchange Views check box is selected. OWA for Exchange 2003 will only show custom views if this option is selected.
|
The Conversation field is based on the message's Subject field. When you create a new item in a folder, the Conversation field is automatically filled in with the content of the item's Subject field. Any replies inherit the Conversation field from the original item.
The Conversation Index is a unique identifier used by Outlook to track the series of responses to an item. This index allows Outlook to know which item in the thread the user is responding to and where the response should be placed in the threaded view.
To implement threaded views for any of your Outlook folders, you must group by the Conversation field and sort in ascending order by the Conversation Index. Most developers forget about the step of sorting by the Conversation Index when they try to implement threading. Without it, your view will be grouped only by the Conversation Index and will have no indented text indicating responses to items.
To implement threaded views in Outlook folders, follow these steps:
-
From the View menu, choose Arrange By, and then Current View, and then click Customize Current View.
-
Click the Group By button. Be sure the Automatically Group According To Arrangement check box is not selected.
-
In the Group Items By area, select Conversation and then click OK.
-
Click the Sort button.
-
In the Sort Items By area, select Conversation Index. To see this property, you might have to select All Mail Fields from the Select Available Fields From drop-down list.
-
Click OK twice.
Figure 3-23 shows a threaded view.
Note | In all folders except those based on e-mail items, Outlook does not automatically make the Post Reply To This Folder menu command available. This command allows you to post replies in a folder that automatically inherit the conversation property from the original item. To enable this command, you can add it to the Outlook menu or toolbar. |