Outlook 2007 Contacts List in VC++ .net RRS feed

  • Question

  • Hi there.

    I am a MFC developer, and have a bit taste of vc++.Net applications. The task i want to do in .net form bassed application is to communicate with MS. Outlook 2007 and get the contacts from outlook to display in some controll over the form.
    I'v read a little about #import and COM etc. but really dont know which is the rightr direction to proceed the study for this issue.
    Can someone guide me that which technique is available for such type of applications, and what shuld i study to do such works in VC++ .Net 2005 / 2008.  Can anyone refer some tutorial or Docs?

    • Moved by Tim Li Monday, April 6, 2009 5:17 AM off-topic
    Sunday, March 29, 2009 3:32 PM

All replies

  • Hello Merhan,

    have a look here:



    For Outlook 2007 I would use the Table-Object of the Contact MAPIFolder to get faster access to the Items.

    However - if you programm in C++ - it's not too hard to use Extended MAPI to access those Items using the native API instead.

    This is much faster and don't showing security warnings.

    If you plan to use the Outlook Object Model, you need to import the Outlook.tlb into your Project or add a reference to the Microsoft Outlook 12.0 Object Library.

    Right Click on your MFC Project and the references you need. However - I would prefer using extended MAPI in that scenario.
    For further questions it's better to ask in a Forum more specific to c++ programming and no VSTO.

    Hope this gives you a start.

    Greets - Helmut
    Helmut Obertanner [http://www.x4u.de] [http://www.outlooksharp.de]
    Tuesday, March 31, 2009 6:10 AM
  • Hello Sir.

    My task was to get outlook contacts in MFC. So i used the following documentation and got my outlook 2007 application in my own mfc exe.


    Here, I can invoke the outlook.exe and creat and save a CONTACT Item, mail item... etc.

    But i want to VIEW all the contact items saved in OUTLOOK. Can you please help me the classes and APIs available for this purpose?
    Here is a sample code to save a new Contact.

      CApplication olApp;
       COleException e;
       if(!olApp.CreateDispatch(L"Outlook.Application", &e)) {
          CString str;
          str.Format(L"CreateDispatch() failed w/error 0x%08lx", e.m_sc);
          AfxMessageBox(str, MB_SETFOREGROUND);
       CContactItem  olItem(olApp.CreateItem(2));
       olItem.AddPicture(L"C:\\Documents and Settings\\Mehran\\Desktop\\090330114134_14.jpg");
       olItem.put_FirstName(L"Test Name");

    I want to get all my contacts in MFC. Can anyone help me Please?

    Wednesday, April 1, 2009 2:51 PM
  • I'm sorry, but this is off-topic in the VSTO forum. VSTO is a particular technology and it doesn't include the programming language you're using. You therefore won't find the technical competence in the forum to answer your question. I suggest you ask this in the Outlook programming newsgroup, where you'll find specialists in Outlook and  C++.
    And I'll find the entry of the newsgroup in following post:
    PLEASE READ FIRST - What is VSTO and non-VSTO resources

    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, April 6, 2009 5:16 AM