Fetching Outlook Categories: ATL / COM add-in

  • Thread starter Thread starter Rod Fitzsimmons Frey
  • Start date Start date
R

Rod Fitzsimmons Frey

I'm trying to fetch the categories exposed by the Outlook Namespace. I'm
executing this code:

CComPtr<Outlook::_NameSpace> pSession;
m_Application->get_Session(&pSession);
Outlook::_Categories * pCategories = NULL;
pSession->get_Categories(&pCategories);

which is raising an exception : Access violation writing location 0x3005ce28.

I'm doing this during the OnConnection message of the Application. pSession
seems to be valid.

Any pointers? Clearly I'm making some bonehead mistake.

Thanks!
Rod
 
I can't help with C++/ATL code, but does it work if you wait until the
OnStartupComplete event fires? What about a timer that fires to execute that
code some time after OnStartupComplete fires?
 
My code, ( in OL 2007 ) which works:

Outlook::_NameSpacePtr NS;
if(NS = spApp->GetNamespace(L"MAPI")){
_CategoriesPtr spCats = NS->Categories;

is essentually the same as yours. ( ignoring the smartpointers )
It's executed in the OnConnection event.
 
Back
Top