Click here to Skip to main content
13,449,155 members (52,970 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 7 Oct 2009

Outlook 2007 CPU Monitor AddIn

, 7 Oct 2009
Rate this:
Please Sign up or sign in to vote.
A cool CPU Monitor AddIn for Outlook 2007


This Addin for Outlook 2007 adds a custom task pane that monitors the CPU and memory usage for the local machine or a remote machine, condition to your permissions on that remote machine. This is a sample for a cool VSTO implementation inside Outlook 2007. The Monitor control is a control from Niel M.Thomas' article A thermometer control, so thank you Niel.

The Addin adds a button to the standard toolbar on Outlook Explorer name "CPU Monitor". You can launch as many task panes as you want and connect each one to a different machine. The machine name is stored in an XML file in your temp directory, each time Outlook opens, the XML file is loaded and your setting for the Addin is preserved. The two buttons at the bottom of the custom task pane launch the Remote Desktop Connection on to the computer that is assigned to the task pane, or launch the computer management console connected to the same computer.


Office Business Applications (OBA) are an emerging breed of applications that leverage the power of the Office Business Platform, that is, the clients, servers, services, and tools that comprise the 2007 Microsoft Office system. That said, this Addin will help you monitor a computer/server for high CPU or memory usage from inside Microsoft Outlook 2007. The Addin was developed with VS 2008 and VSTO 3.1.

Using the Code

First, we need to create a VSTO project for Outlook 2007 and add a user control to our project.
Next, we start working on our user control. In this user control, I added Niel's Thermometer control and a prefCounter to monitor the CPU and memory of a machine. I configure the prefCounter to the "% Processor Time" for the CPU and another one to "Committed Bytes" for the memory usage. I started a Timer control to check these properties each sec.

Here is the Tick event for the Timer control:

//calculate the values of the monitors.
int num = Convert.ToInt32(Math.Ceiling((double)this.perfCounter.NextValue()));
cpuMonitor1.Value = (float)num;
toolTip1.SetToolTip(cpuMonitor1, num.ToString() + "%");
int maxMemory = Convert.ToInt32(Math.Round((double)this.perfCounter2.NextValue() / 
	Math.Pow(1024, 2)));
cpuMonitor2.Max = maxMemory;
cpuMonitor2.Interval = maxMemory / 10;
int memory = Convert.ToInt32(Math.Ceiling((double)this.perfCounter1.NextValue()) / 
	Math.Pow(1024, 2));
cpuMonitor2.Value = (float)memory; 
toolTip1.SetToolTip(cpuMonitor2,"Commit Charge: "+ memory.ToString()+"M / " + 

Next, we need to add our button to the Outlook Explorer standard toolbar.

// Create the button in the standard toolbar.
newButton = (Microsoft.Office.Core.CommandBarButton)
	missing, missing, missing, missing);
newButton.Caption = "CPU Monitor";
newButton.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;
newButton.Picture = MyHost.GettIPictureDispFromPicture
newButton.Tag = "CPUMonitor";
newButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler

Now, let's look at the button click event:

myUserControl1 = new CPUMonitor(computerName,ds);
myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "CPU Monitor Task Pane");
myCustomTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
//myCustomTaskPane.Height = 500;
myCustomTaskPane.Width = 195;
myCustomTaskPane.DockPositionRestrict =
myCustomTaskPane.VisibleChanged += new EventHandler(myCustomTaskPane_VisibleChanged); 
myCustomTaskPane.Visible = true;

That's it. All the other stuff inside the code is for reading the XML file into a DataSet and using it to determine which computer to connect to, and if we need to show the task pane next time Outlook opens or not.

Points of Interest

This is a cool usage of VSTO and Outlook Addin.
Hope you will learn from it and develop more fun and cool Addins for Office.

Again, thank you Niel, VERY COOL CONTROL!


  • 7th October, 2009: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ron Levy
Software Developer
Israel Israel
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
hth20007-Oct-09 7:48
memberhth20007-Oct-09 7:48 
GeneralRe: My vote of 1 Pin
Ron Levy7-Oct-09 20:11
memberRon Levy7-Oct-09 20:11 
GeneralRe: My vote of 1 Pin
SteveKing7-Oct-09 22:39
memberSteveKing7-Oct-09 22:39 
GeneralRe: My vote of 1 Pin
Dean Mills8-Oct-09 1:31
memberDean Mills8-Oct-09 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180318.3 | Last Updated 7 Oct 2009
Article Copyright 2009 by Ron Levy
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid