Click here to Skip to main content
13,089,943 members (48,150 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 11 Aug 2006

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

, 11 Aug 2006
Rate this:
Please Sign up or sign in to vote.
This Outlook add-in will create a Command Bar button in the Standard Tool buttons collection. This utility will automatically send the draft mails.

Sample Image - OutlookAdd-in_small.jpg


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.

  1. Start a new project by choosing File, New Project, Other Projects Extensibility Projects, Shared Add-In. Click OK. Click Next at the Welcome screen.

  2. Page 1 of 5 asks you to select a programming language C#, VB or VC++. Select C#. Click Next.

  3. On Page 2 of 5 Select an Application Host, Select Microsoft outlook. Click Next.

  4. On Page 3 of 5 name the add-in MyAddin and enter a description; for example, My First Add-In. Click Next..

  5. 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.

  6. 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<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>

OnAddInsUpdate <o:p>

Occurs whenever an add-in is loaded or unloaded from the Visual Studio integrated development environment (IDE).  <o:p>


OnBeginShutdown <o:p>

Occurs whenever the Visual Studio integrated development environment (IDE) shuts down while an add-in is running.  <o:p>


OnConnection <o:p>

Occurs whenever an add-in is loaded into Visual Studio.  <o:p>


OnDisconnection <o:p>

Occurs whenever an add-in is unloaded from Visual Studio.  <o:p>


OnStartupComplete <o:p>

Occurs whenever an add-in, which is set to load when Visual Studio starts, loads.  <o:p>

<o:p>I have used OnStartupComplete(ref System.Array custom) method to create a CommandBarButton. The CommandBarButton is then added to the Standard CommandBar. 

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.
    automateButton = (CommandBarButton)
      oStandardBar.Controls["Automate Mails"];
    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 

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;
    oCommandBars = (CommandBars)
      BindingFlags.GetProperty , null, applicationObject, null);
    // Outlook has the CommandBars collection
    // on the Explorer object.
    object oActiveExplorer;
    oCommandBars= (CommandBars)
      BindingFlags.GetProperty, null, oActiveExplorer, null);
// Set up a custom button on the "Standard" commandbar.
    oStandardBar = oCommandBars["Standard"]; 
    // 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;

Mail Automation Window

Double Click any Draft mail in Automation Window will open up a window where user can set the time.

Sample screenshot

The mails will be send automatically at the selected time.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Lalit Singh Sisodia
Web Developer
India India
Dedicated to my wife Smita Lalit Sisodia and daughter Bhavya Sisodia

You may also be interested in...


Comments and Discussions

GeneralA simple and elegant example showing how to write add-on. Pin
Rajganesh Mountbatton6-Jul-09 22:51
memberRajganesh Mountbatton6-Jul-09 22:51 

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
Web01 | 2.8.170813.1 | Last Updated 11 Aug 2006
Article Copyright 2006 by Lalit Singh Sisodia
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid