Eric's Blog

Day to day experience in .NET
Welcome to Blogs @ IRM Sign in | Join | Help
 Search

Disclaimer

The content of this site is my own personal opinion and does not in any way represent my employer, it's subsideries or affiliates. These postings are provided "AS IS" with no warranties, and confer no rights.

This Blog

Custom Task Panes in Outlook 2007

So far, all my Outlook add-in posts have covered different aspects of gathering data from the user. It would also be nice if the user could get some nice presentation of this data, making it worthwhile putting it in. For this I have chosen to implement a custom task pane, that I have added and only displays when the calendar is active.
 
Work Overview
 
The graph shows how I have spent my time for the time period in the datetime pickers. There is a new DisplayedDates property on the CalendarView that is supposed to return the dates displayed in the calendar, but unfortunately it does not work, and it is a confirmed bug.
Below the graph I have a couple of different possibilities to export the data to some Excel-files and also to send an e-mail with invoice information to the person responsible of doing invoicing. All the Excel-files are created with code and I have a reference set to the Excel interop assembly.
 
//Task Pane
taskPane = this.CustomTaskPanes.Add(new IRM.Office.Outlook.WorkItemOverview(this.calendar), "IRM");
taskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;
 
//Hook events
explorer = Application.ActiveExplorer();
explorer.BeforeFolderSwitch += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_BeforeFolderSwitchEventHandler(explorer_BeforeFolderSwitch);
 
The task pane user interface is just a regular user control. The last two lines catches the BeforeFolderSwitchEvent in which I hides or shows the task pane depending on the selected folder.
 
bool isInCalendar = ((MSOutlook.Folder)newFolder).Name == calendar.Name;
this.taskPane.Visible = isInCalendar;
 
To gather the information from the calendar I'm using the new Table, and the just loops through the rows extracting my attachments.
 
public static MSOutlook.Table GetAppoinmentsForPeriod(DateTime start, DateTime end)
{
    MSOutlook.Folder calendar = IRM.Outlook.Globals.ThisAddIn.Calendar;
    System.Globalization.CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture;
 
    string filter = string.Format(@"[Start] > ""{0}"" And [End] < ""{1}""", start.AddMinutes(-1).ToString("d", culture), end.AddDays(1).ToString("d", culture));
 
    MSOutlook.Table table = calendar.GetTable(filter, MSOutlook.OlTableContents.olUserItems);
 
    table.Columns.RemoveAll();
 
    table.Columns.Add("EntryID");
    table.Columns.Add("Start");
    table.Columns.Add("End");
    table.Columns.Add("Sensitivity");
 
    table.Sort("Start", Type.Missing);
 
    return table;
}
 
In the code above I first define my query, getting the table, choosing the columns I'm interested in and finally setting the sort order.
This is probably my last Outlook post for a while, since I have covered the most interesting parts of my add-in. I have used it for three months soon and it works great, and as I wrote in my first post I'm quite impressed of how far Microsoft have come with Outlook extensibility.
 
Published den 18 februari 2007 22:48 by ericqu
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Mark said:

Hi, I've created a custom task pane, however I'm trying to display this in the Explorer folder view, or Reading pane. I can add my Task Pane to the inspector window fine, but I require it adding to the folder view. here's what I've tried... // Get active explorers m_explorers = Application.Explorers; // For each explorer, add the custom task pane to the folder view. foreach(Outlook.Explorer exp in m_explorers) { try { ctp = Globals.ThisAddIn.CustomTaskPanes.Add(new MessageStreamForm(), "MessageStream Live", exp.CurrentFolder); ctp.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } Please help!
januari 22, 2009 16:11
 

Eric's Blog said:

Three years ago (can’t believe it’s been so long) I blogged about creating an Outlook add-in. The add-in
februari 1, 2010 14:37

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems