Easy Way to Integrate Your Application With Outlook.

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,
                       GetIDispatch(FALSE), 
                       __uuidof(Outlook::InspectorsEvents));
  }
  //
  // 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
   m_dlg.DisplayMailItem(mailItem); 
  }
 }
}

Downloads

Download demo project - 28 Kb
Download source - 33 Kb


Comments

  • Originate 2013 a new color layout Nike Sense Max shoes

    Posted by Tufffruntee on 04/25/2013 07:39am

    Qualifying series Nike Air Max HomeTurf metropolis recently absolutely comes up, this series in the classic Tune Max shoes to London, Paris and Milan [url=http://www.nikeskornatet.se/nike-free-run-2-c-29/]nike free run 2 sverige[/url] the three paid glorification to the iconic conurbation of Europe, combined with the characteristics of the three cities, Air Max 1 HYP,Mood Max 90 HYP,With Max 1 and shoes such as Superiority Max 95, combined with the Hyperfuse, as by a long chalk as a order of materials, such as suede, Whether you require operational or retro-everything. It seems to me that more than Nike [url=http://www.nikeskorrea.se/nike-air-max-90-hyperfuse-c-37/]air max 90 hyperfuse[/url] shoes all star spirited decorous signature shoe series, and NSW series, all take the lead color system of the new Display Max Hyperposite exposure. Shaft light brown provoked, hyperfuse, swoosh, and are attached at the down of the yellow/orange gradient snap details, lining is a Galaxy in [url=http://www.nikeskoroutlet.se/]nike skor[/url] orange prototype garter, extraordinarily beautiful.

    Reply
  • How can i make similar COM for Outlook Express

    Posted by parabiz on 06/13/2005 09:30am

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

    Reply
  • Get Selected Folder instead

    Posted by Legacy on 02/08/2004 12: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 ?

    Reply
  • Problem with Outlook and Addin.dll

    Posted by Legacy on 01/28/2004 12: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 ?????????


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

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

    Originally posted by: Shahaji Bhosle

    Hi
    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
    in SELECTION CHANGE Event.

    Any Help Will be Appreciated.

    Bye

    Shahaji
    Shahaji@lelesys.com
    Pune India

    Reply
  • Catching Events such as "New Contact"

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

    Originally posted by: John

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

    Need Help !

    Reply
  • ATL/COM

    Posted by Legacy on 11/04/2003 12: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

    Reply
  • _MailItem

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

    Originally posted by: aurel

    Does anyone know how to send attachments using _MailItem?

    Thanks, much.

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

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

    Originally posted by: Koundinya

    Hi
    
    

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

    thanks
    Koundinya

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

    Posted by Legacy on 08/13/2002 12: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.
    
    Thanks
    with regards
    senthil kumaran


    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • One of the most foolproof ways for an online system to confirm, "Is it really you?" is by adding two-factor authentication. Modern two-factor solutions have evolved to support new, complex technology models that change how we use data, including cloud computing and bring-your-own-device (BYOD). However, not all two-factor authentication solutions are created equal. This guide walks through some of the key area of differentiation between two-factor authentication solutions and provides some concrete criteria …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds