Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Outlook AddIn
hi
Outlook add-in using VC++ ATL/COM[^]
i had use this article and try to create Folder with Buttonclicked method.
But Outlook crash when i try ti initialize _ApplicationPtr pApp
_ApplicationPtr pApp;
		_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("test"));
		pNewContact->Save();
 

 
i am just lern com outlook(
tnx
Posted 20-Mar-13 6:10am
Comments
Eugen Podsypalnikov at 20-Mar-13 11:20am
   
// But Outlook crash when i try ti initialize _ApplicationPtr pApp
But... there is no any initializing here... :)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

HRESULT hr= CoInitialize(NULL);
    hr=pApp.CreateInstance(__uuidof(Application));
	_NameSpacePtr pNamespace;
	pApp->GetNamespace(L"MAPI",&pNamespace);
	MAPIFolderPtr pFolder;
	pNamespace->GetDefaultFolder(olFolderContacts,&pFolder);
	_ItemsPtr pItems;
Solved
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 24 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100