Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment: Win 98/NT/2000/Me/XP Outlook (Office 9.0)

Here is a sample that would easily integrate with the outlook application and would respond to some usual events. Even though there is documentation available for Outlook automation objects, the naming convention which is used is very confusing and misleading. Class 'Inspectors' can be used as a mail watcher to allow notification when a mail is opened by the user. In the same way class 'Explorer' is used to display mails in the mail folder.

Now you know why we need this sample!!.

Note: You need to run this application only after opening Outlook.

// Following are the includes you might need to 
// find the actual location and modify following imports 
#import "C:\\Program Files\\Common Files\\Designer\\msaddndr.dll"
#import "D:\\Microsoft Office\\Office\\Mso9.dll"
#import "D:\\Microsoft Office\\Office\\Msoutl9.olb"


//connect to outlook & watch for some events
if(m_outlook == 0) {
 if(m_outlook.CreateInstance(__uuidof(Outlook::Application)) == S_OK) 
  Outlook::_InspectorsPtr inspectors; 
  //get inspectors and make event sink connection
  if(m_outlook->get_Inspectors(&inspectors) == S_OK) {
   //use helper method to sink into 
   CEventSink::Advice( inspectors,
  // get explorer(mail listing window)
  // make event sink connetion
  new CEventSink(*this,m_outlook->ActiveExplorer());


// when mail is opened in a seperate window(following 
// event is fired)
void COutlooksampleDlg::NewInspector(IDispatch *disp)
 // connect a event sink for this mail
 new CEventSink(*this,disp);


// when mail shown in preview window

void CEventSink::SelectionChange()
 long count = 0;
 if(m_explorer != 0) {
  Outlook::SelectionPtr& selection =m_explorer->Selection;
  if(selection->get_Count(&count) == S_OK && count > 0) 
   Outlook::_MailItemPtr mailItem = selection->Item((short)1);
   //display this in edit box


Download demo project - 28 Kb
Download source - 33 Kb


  • How can i make similar COM for Outlook Express

    Posted by parabiz on 06/13/2005 04:30pm

    Hi, How can i make the similar COM Add In for Outlook Express Your help will be greatly appreciated. Thanks, Jay

  • Get Selected Folder instead

    Posted by Legacy on 02/08/2004 08:00am

    Originally posted by: Bjoern Schultze

    Anyone could explain me, how I can modify the code to Get the selected Folders instead of Message-Previews ?

  • Problem with Outlook and Addin.dll

    Posted by Legacy on 01/28/2004 08:00am

    Originally posted by: Hela Malz

    I built AddIn.dll (MFC, Interface _IDTExtensibility2) for Outlook.
    It has always been executed by Outlook, even it wasn't 'registered' through ... - Options - COM-Add-Ins
    When I renamed AddIn.dll to AddIn1.dll, Outlook didn't execute it any more.
    After renaming back to AddIn.dll Outlook still refuses to execute my AddIn.dll
    I tried 'registering' my AddIn.dll through ... - Options - COM-Add-Ins, but AddIn.dll is not showed there

    What can I do, that Outlook executes my dll again ?????????

  • Any help in modifying this appl.. as.........plz read on...

    Posted by Legacy on 12/11/2003 08:00am

    Originally posted by: Shahaji Bhosle

    I compile and run this appl.
    No pbm at all.
    This example is excellent resource
    for OUTLOOK add-in beginners.

    I am going to modify this appl. as
    i should display a messagebox without
    running the application.
    In my project i am adding someothat code

    Any Help Will be Appreciated.


    Pune India

  • Catching Events such as "New Contact"

    Posted by Legacy on 11/18/2003 08:00am

    Originally posted by: John

    How can I catch an event such as create an new contact, or
    add a new folder.

    Need Help !


    Posted by Legacy on 11/04/2003 08:00am

    Originally posted by: riaz

    I want to add a button to the outlook toolbar

    this button should also appear on teh child windows (New message window, reply window, etc)

    Pls Help

  • _MailItem

    Posted by Legacy on 10/29/2002 08:00am

    Originally posted by: aurel

    Does anyone know how to send attachments using _MailItem?

    Thanks, much.

  • How to get the mail items while activating my application or out look

    Posted by Legacy on 10/10/2002 07:00am

    Originally posted by: Koundinya


    I wnat to know, how we can fetch all mail items while actiavting Outlook or application


  • Excellent work---I need help to get the Message ID from mailItem

    Posted by Legacy on 08/13/2002 07:00am

    Originally posted by: Senthil Kumaran

    Excellent Work,but i could't read MessageID(mail header) from Outlook::_MailItemPtr mailItem pointer,i need ur help.
    with regards
    senthil kumaran

  • How do I get the sender's mailaddress?

    Posted by Legacy on 08/09/2002 07:00am

    Originally posted by: HU Youchang

    I am trying to get the sender's mailaddress
    from a MailItem.
    Could you help me?

    Thank you.

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date