Outlook Add-in: Set the time for your draft mails, for sending the mails at particular time in Microsoft Outlook 2003






2.40/5 (5 votes)
Aug 11, 2006
2 min read

30760

541
This Outlook add-in will create a Command Bar button in the Standard Tool buttons collection. This utility will automatically send the draft mails.
Introduction
This utility will set the time for your draft mails. And will automatically send the mails.
This article will give you an basic idea how to create an add-in for the Microsoft applications.
Steps to create a add-in project in VS.Net 2003.
-
Start a new project by choosing File, New Project, Other Projects Extensibility Projects, Shared Add-In. Click OK. Click Next at the Welcome screen.
-
Page 1 of 5 asks you to select a programming language C#, VB or VC++. Select C#. Click Next.
-
On Page 2 of 5 Select an Application Host, Select Microsoft outlook. Click Next.
-
On Page 3 of 5 name the add-in MyAddin and enter a description; for example, My First Add-In. Click Next..
-
On Page 4 of 5 we want to indicate that the add-in can be invoked from the Tools menu, the add-in should load when the host loads, and the add-in should be available to all users. (Check all check boxes.) Click Next.
-
On Page 5 of 5, review the Summary information, and if it is correct, click Finish.
With the above steps 2 projects will be created. One is class library and the other is Set up project. The output of setup will be used to install the Add-in.
The Class library will consist of Connect class which inherits Object class and implements
Extensibility.IDTExtensibility2. The method definition for all the methods in IDTExtensibility2 will already be present with the summary. These methods can be used to implement your add-in. Following are the IDTExtensibility2 Methods:
Public |
Occurs whenever an add-in is loaded or unloaded from the Visual Studio integrated development environment (IDE). | |
Public |
Occurs whenever the Visual Studio integrated development environment (IDE) shuts down while an add-in is running. | |
Public |
Occurs whenever an add-in is loaded into Visual Studio. | |
Public |
Occurs whenever an add-in is unloaded from Visual Studio. | |
Public |
Occurs whenever an add-in, which is set to load when Visual Studio starts, loads. |
Following is the code to create a CommandBarButton:
private Microsoft.Office.Core.CommandBarButton automateButton;
// In case the button was not deleted, use the exiting one.
try
{
automateButton = (CommandBarButton)
oStandardBar.Controls["Automate Mails"];
}
catch(Exception)
{
object omissing = System.Reflection.Missing.Value ;
automateButton = (CommandBarButton) oStandardBar.Controls.Add(1,
omissing , omissing , omissing , omissing);
automateButton.Caption = "Automate Mails";
automateButton.Style = MsoButtonStyle.msoButtonCaption;
}
automateButton.OnAction = "!<MyCOMAddin.Connect>";
automateButton.Visible = true;
automateButton.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
this.AutomateButton_Click);
This button is added to the Standard CommandBar. Following is the code to get the Standard CommandBar from the Outlook object.
CommandBars oCommandBars;
CommandBar oStandardBar;
try
{
oCommandBars = (CommandBars)
applicationObject.GetType().InvokeMember("CommandBars",
BindingFlags.GetProperty , null, applicationObject, null);
}
catch(Exception)
{
// Outlook has the CommandBars collection
// on the Explorer object.
object oActiveExplorer;
oActiveExplorer=
applicationObject.GetType().InvokeMember(
"ActiveExplorer",BindingFlags.GetProperty,
null,applicationObject,null);
oCommandBars= (CommandBars)
oActiveExplorer.GetType().InvokeMember("CommandBars",
BindingFlags.GetProperty, null, oActiveExplorer, null);
}
// Set up a custom button on the "Standard" commandbar.
try
{
oStandardBar = oCommandBars["Standard"];
}
catch(Exception)
{
// Access names its main toolbar Database.
oStandardBar = oCommandBars["Database"];
}
The Button click handler will open up the Automate window. Where the user can set the time for all the Draft messages.
private void AutomateButton_Click(Microsoft.Office.Core.CommandBarButton
cmdBarbutton, ref bool cancel)
{
mailAutomationObject.oApp = (Outlook.Application)applicationObject;
mailAutomationObject.ShowDialog();
}
Double Click any Draft mail in Automation Window will open up a window where user can set the time.
The mails will be send automatically at the selected time.