Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C++
_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
Comments
Eugen Podsypalnikov 20-Mar-13 11:20am    
// But Outlook crash when i try ti initialize _ApplicationPtr pApp
But... there is no any initializing here... :)

1 solution

C++
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900