G
Guest
I have a very simple COM-add-in where I try to access a folder.
But the direct access by index fails:
CComPtr<Outlook::_NameSpace> NameSpace;
m_spApp->GetNamespace(L"MAPI", &NameSpace);
CComPtr<Outlook::MAPIFolder> InBoxFolder;
CComPtr<Outlook::MAPIFolder> RootFolder;
NameSpace->GetDefaultFolder(Outlook:lFolderInbox, &InBoxFolder);
InBoxFolder->get_Parent((IDispatch **)&RootFolder);
CComPtr<Outlook::_Folders> Folders;
RootFolder->get_Folders(&Folders);
Outlook::MAPIFolder * pFolder = NULL;
HRESULT hr = Folders->GetFirst(&pFolder);
ATLASSERT(hr == S_OK);
hr = Folders->Item(CComVariant(0), &pFolder);
ATLASSERT(hr == S_OK);
The second ATLASSERT() fails (out of bounds) whereas the first succeeds! Why?
But the direct access by index fails:
CComPtr<Outlook::_NameSpace> NameSpace;
m_spApp->GetNamespace(L"MAPI", &NameSpace);
CComPtr<Outlook::MAPIFolder> InBoxFolder;
CComPtr<Outlook::MAPIFolder> RootFolder;
NameSpace->GetDefaultFolder(Outlook:lFolderInbox, &InBoxFolder);
InBoxFolder->get_Parent((IDispatch **)&RootFolder);
CComPtr<Outlook::_Folders> Folders;
RootFolder->get_Folders(&Folders);
Outlook::MAPIFolder * pFolder = NULL;
HRESULT hr = Folders->GetFirst(&pFolder);
ATLASSERT(hr == S_OK);
hr = Folders->Item(CComVariant(0), &pFolder);
ATLASSERT(hr == S_OK);
The second ATLASSERT() fails (out of bounds) whereas the first succeeds! Why?