none
STDMETHOD(ButtonClicked)(IDispatch* ribbon) and MAPI RRS feed

  • Question

  • Hi.

    I had try to create contact item in Outlook 2010 - but had a problem.When i use code like in ButtonClicked method  this Outlook crash

    _ApplicationPtr pApp("Outlook.Application");
    _NameSpacePtr pNamespace;
    MAPIFolderPtr pFolder;
    _ItemsPtr pItems;
    _ContactItemPtr pNewContact;
    pApp->GetNamespace(L"MAPI",&pNamespace);
    pNamespace->GetDefaultFolder(olFolderContacts,&pFolder);
    pApp->CreateItem(olContactItem,(IDispatch**)&pNewContact);
    pNewContact->put_LastName(OLESTR("Test"));
    pNewContact->put_FirstName(OLESTR("Test2"));
    pNewContact->Save();

    When i use it at Onconnection Method - it work good.

    I had just learn com(

    Help me to initialize  ApplicationPtr pApp

    Wednesday, March 20, 2013 2:43 PM

Answers

  • Is that a COM add-in? Why are you creating a new instance of the Outlook.Application object? It is passed to you in the OnConnection() callback.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by Loik Maksim Wednesday, March 20, 2013 3:23 PM
    Wednesday, March 20, 2013 3:09 PM

All replies

  • Is that a COM add-in? Why are you creating a new instance of the Outlook.Application object? It is passed to you in the OnConnection() callback.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by Loik Maksim Wednesday, March 20, 2013 3:23 PM
    Wednesday, March 20, 2013 3:09 PM
  • yes its com add-in and its passed in Onconnection().

    Hm now i think i see my problem - i just need to use same instance.

    I ll trr it.

    Tnx

    Wednesday, March 20, 2013 3:17 PM
  • tnx )

    Now its work

    Wednesday, March 20, 2013 3:22 PM