![]() |
Enterprise Systems »
Office Development »
Outlook
Intermediate
License: The Code Project Open License (CPOL)
How to programmatically create an Outlook home folder page in the Outlook Today styleBy Andrei SmolinOutlook Today is a sample of a 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++). |
VBScript, C# 1.0, C# 2.0, C# 3.0, VB 7.x, VB 8.0, VB 9.0, Windows (Win2K, WinXP, Win2003, Vista), .NET (.NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5), Office, Visual Studio (VS.NET2003, VS2005, VS2008), COM, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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:
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:
<html>
<head>
<title>VBScript: the first try</title>
</head>
<body>
</body>
Our custom page consists of the HTML tag that contains the head and body tags. The page is empty, as you can see. Now, let's add a button:
...
<body>
<input type="button" value="Go" onClick="greeting()"/>
</body>
...
The button caption is "Go", and when you click on the button, the Greeting function is called. Now, let's add the function:
...
<head>
<script type="text/vbscript">
function greeting()
document.write("<p>Hello, developer!</p>")
end function
</script>
</head>
...
This simple function prints a paragraph containing the greeting. Now, we are ready to plug the page into Outlook:

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:
As always, Google is a good helper: just search for HTML Tutorial.
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:

Application is the most important Outlook class. It provides the Session property of type NameSpace. The NameSpace class contains Folders. Each Folder (type Folder in Outlook 2007, MAPIFolder in Outlook 2000-2003) contains Items and other Folders. Each Item provides a Class property, the value of which is a constant uniquely identifying every item type: MailItem, TaskItem, 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:
function greeting()
on error resume next
dim OutlookApp
on error resume next
set OutlookApp = GetObject(, "Outlook.Application")
if OutlookApp is Nothing then
document.write("<p>Hello, developer!</p>")
exit function
else
document.write("<p>Hello, Outlook developer!</p>")
end if
on error goto 0
dim folderCount
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
dim fldr
set fldr = OutlookApp.Session.Folders.Item(i)
document.write("<li>" & fldr.Name & "</li>")
next
document.write("</ul>")
document.title = "VBScript: the first try"
end function
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.
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 4 Aug 2008 Editor: Smitha Vijayan |
Copyright 2008 by Andrei Smolin Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |