Outlook Today is a sample of custom Outlook home folder page. In this article, you will learn how to create such a page in VBScript and in .NET (VB, C#, C++).
There are two ways of customizing Outlook Today:
- It can be modified by the user; you just need to open Outlook Help (see the Help menu) and enter "customize Outlook today" in the Search For field.
- Or, if you are a developer, you may want to add some functionality to Outlook Today programmatically. Let's dig deeper into this.
Outlook Today is a set of HTML pages that use VBScript to display some Outlook-related information. If you open the Properties window for Personal Folder and navigate to the Home tab, you'll see that the default page address is: res://C:\Program Files\Microsoft Office\OFFICE11\1033\outlwvw.dll/outlook4.htm.
That is, the first Outlook Today page is shown from the resources of some Outlook-related DLL, and this implies that no source code is available for Outlook Today.
In other words, the developer can only replace Outlook Today with a custom page. Let's create such a page: open Notepad and copy / paste the text below:
<title>VBScript: the first try</title>
Our custom page consists of the HTML tag that contains the
body tags. The page is empty, as you can see. Now, let's add a button:
<input type="button" value="Go" onClick="greeting()"/>
The button caption is "Go", and when you click on the button, the
Greeting function is called. Now, let's add the function:
This simple function prints a paragraph containing the greeting. Now, we are ready to plug the page into Outlook:
- Right-click on a folder and choose Properties in the context menu. Note that if the folder is Personal Folders, it means that we replace the Outlook Today page with our custom one.
- Specify the page location and tick the checkbox that shows the page.
Note that the Address textbox in the screenshot above corresponds to the
WebViewUrl property of the
MAPIFolder class (
Folder in Outlook 2007). Accordingly, the checkbox labeled as "Show home page by default for this folder" corresponds to the
WebViewOn property. These properties allow you to set an HTML page for any Outlook folder on the fly. For instance, you can replace the Outlook Today page with your custom one. If you use these properties, you should keep in mind that Outlook 2002 has a well-known bug confirmed by Microsoft: when you set
WebViewUrl, the page will show up after the user switches to another folder, and then switches back to the folder with the home page (see the Microsoft website for details).
Here is the page:
At this stage, you can move in the following directions:
- Learn HTML.
As always, Google is a good helper: just search for HTML Tutorial.
- Learn VBScript.
Here is a highly recommended guide: MSDN.
However, Outlook Today can display some information about tasks, e-mails / messages, and appointments and meetings. To get these data as well as information about contacts, notes, and other Outlook items, you have to dig into the Outlook object model:
- Open Outlook
- Choose Tools | Macros | Visual Basic Editor in the menu or just press Alt+F11
- In the VB IDE, choose View | Object Browser in the menu or just press F2
Application is the most important Outlook class. It provides the
Session property of type
NameSpace class contains
Folder in Outlook 2007,
MAPIFolder in Outlook 2000-2003) contains
Items and other
Item provides a
Class property, the value of which is a constant uniquely identifying every item type:
ContactItem, etc. To get help on a class or a class member, just press F1. When reading help, pay attention to the availability and other aspects of using a class or class member in VBScript. For instance, Outlook events are not available in VBScript. The following sample function uses the Outlook object model to demonstrate how you can apply the above-mentioned information. The function lists top-level folders in the current Outlook session:
on error resume next
on error resume next
set OutlookApp = GetObject(, "Outlook.Application")
if OutlookApp is Nothing then
document.write("<p>Hello, Outlook developer!</p>")
on error goto 0
folderCount = OutlookApp.Session.Folders.Count
document.write("<p>There are " & folderCount & _
" top-level folders in this session. ")
document.write("Here they are:</p><ul>")
for i = 1 to folderCount
set fldr = OutlookApp.Session.Folders.Item(i)
document.write("<li>" & fldr.Name & "</li>")
document.title = "VBScript: the first try"
When I click the button, the function shows the following output in my Outlook 2003. You can do the same in Outlook 2000, 2002 (XP), and Outlook 2007:
As you can see, it is quite simple.