This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Tuesday, February 5, 2008

Redirecting Outlook Reminders

Today's article will guide you through creating an add-in to Outlook 2003 to send alerts to another computer when a reminder is raised.

I worked with the new Visual Studio 2005 Tools for Microsoft Office (VSTO 2005) newly released support for Microsoft Outlook (currently beta). At that point, it was enough to just get it installed, set up the snippets, and take a look at the samples. I created a starter project to demonstrate creating a new mail item and task. Of course it was just a stepping stone to the great things you can do with the beta, but I wanted to do something useful this time.
I don't know about you, but in my house I have my laptop that floats from room to room, a main desktop in the office, a media center computer, my wife's computer, and other assorted boxes awaiting upgrades or repair. I have Outlook installed on my laptop to keep it portable. Obviously, with all of the aforementioned systems, I'm not always sitting in front of my laptop. This means that meeting and task reminders will often go off without me noticing them. Not a good situation!


As they say, necessity is the mother of invention. "Wouldn't it be nice if I could be alerted on a different computer since Outlook is bound to only one?" I thought. Then, it came to me. The new VSTO 2005 for Outlook support was the answer! Why not register for event notifications when a reminder goes off, and raise an alert somewhere else? And from that, Outlook Alerts was born.
Today's article will guide you through creating an add-in to Outlook 2003 to send alerts to another computer when a reminder is raised. In order to follow this article and run the code, you will need any of the Visual Studio Express editions. The code samples in this article are shown in Visual Basic 2005; however, the downloadable source code is available in both VB 2005 and C# 2005. Beta 2 of the Express editions can be downloaded from http://msdn.microsoft.com/express. As with last time, Microsoft Office 2003 (Service Pack 1) is also a requirement, or at least Outlook 2003 SP1. Be aware that Outlook Express will not function as a replacement for Outlook.

The first step in sending alerts remotely is to detect when reminders and alarms are triggered in Outlook. As it turns out, this is easy to hook into, as the main Application object exposes a Reminder event. By registering an event handler for this, you are notified every time the Outlook Reminder dialog appears. The item parameter contains a reference to the item causing the event. This could be a mail item, an appointment, or any other Outlook item supporting reminders. The following method declaration creates a method which will be triggered whenever the Reminder event is raised:

Visual C#
void ThisApplication_Reminder(object item)

Visual Basic
Private Sub ThisApplication_Reminder(ByVal item As Object) Handles

The alerts application has two settings to keep track of. Settings can seem like a challenge. You may not be sure where to store them or what format to use, and writing the code to serialize them and deserialize them can be tedious. Fortunately, the .NET 2.0 framework makes this trivial. Simply right-click the project in the Solution Explorer, then click Properties. Choose the Settings tab and you can create and manage any settings you need. You have the ability to create user or application scope settings with arbitrary names, in a variety of data types. For this project, create a Boolean setting called RemoteRemindersEnabled, and a String setting called RemoteReminderAddress. The first flag controls whether or not alerts will be sent remotely, while the second flag specifies where to send any alerts. The address should be an IP address or net name. Note that unless the other computer is in the same workgroup or domain, it is generally easier to use IP address to guarantee delivery. The Settingsconfiguration should look like this:

(click image to zoom)
Once the settings are created, you can access them in a strongly-typed fashion using the My namespace in Visual Basic as follows:

Visual C#
Properties.Settings.Default.RemoteRemindersEnabled

Visual Basic
My.Settings.RemoteRemindersEnabled

If you use settings, you must provide an easy way to allow users to manage the setting values. Outlook allows you to add menus alongside the built-in menus. This is easy to do and provides a professional look to your add-in. The first step is to obtain a reference to the main menu bar and add a top-level menu; in this case, "Add-in Tasks." The code looks a little messy due to type casting (the CType call) and the two Type.Missing parameters. These are necessary due to the underlying COM nature of the code:

Visual C#
_menuBar = this.ActiveExplorer().CommandBars.ActiveMenuBar;
_helpMenuIndex = _menuBar.Controls[MENU_BEFORE].Index;
_topMenu = (Office.CommandBarPopup)(_menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, _helpMenuIndex, true));
_topMenu.Caption = "Add-in Tasks";
_topMenu.Visible = true;

Visual Basic
_menuBar = Me.ActiveExplorer().CommandBars.ActiveMenuBar_helpMenuIndex = _menuBar.Controls(MENU_BEFORE).Index_topMenu = CType(_menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing,
_helpMenuIndex, True), Office.CommandBarPopup)
_topMenu.Caption = "Add-in Tasks" _topMenu.Visible = True

After creating the menu, you add menu items by calling the Controls.Add() method. Once again, the code looks a little cluttered, but is overall very understandable. The Caption properties in both cases determine what is seen when the menu is opened:

Visual C#
_settingsMenu = (Office.CommandBarButton)(_topMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true));
_settingsMenu.Caption = "Remote Alert Notification Settings...";
_settingsMenu.Visible = true;
_settingsMenu.Enabled = true;

Visual Basic
_settingsMenu = CType(_topMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, True), Office.CommandBarButton)_settingsMenu.Caption = "Remote Alert Notification Settings..."
_settingsMenu.Visible = True
_settingsMenu.Enabled = True

You will still need to create a settings form, and create an event handler to respond to user clicks on the item. At runtime, selecting the Add-in Tasks Remote Alert Notification Settings menu option brings up this custom dialog:





1 comments:

Alexis said...

I'm working on a computer factory where one day I had very disagreeable condition which I had solved thanks to one utility. I dug up this tool at the Inet. It should be good determination for this trouble - how yo recover corrupt pst file.

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger