Delete MAPI folder in Outlook

Joined
Dec 23, 2005
Messages
1
Reaction score
0
I have a function :

void MyClass::DeleteFolders()
{
USES_CONVERSION;
try {
CComPtr<Outlook::MAPIFolder> rootFolder;
CComPtr<Outlook::MAPIFolder> subFolder;
CComPtr<Outlook::_Folders> rootFolders;
CComPtr<Outlook::_Folders> subFolders;
spNameSpace->get_Folders(&rootFolders);
CComVariant ItemRoot("RootFolderName");
rootFolders->Item(ItemRoot, &rootFolder);
rootFolder->get_Folders(&subFolders);
CComVariant ItemSub("SubFolderName");
subFolders->Item(ItemSub, &subFolder);
subFolder->Delete();
rootFolder->Delete();
} catch (...) { };
}
I call it in MyClass::OnDisconection and it does not work.

May be in OnDisconection I can't delete folder ?
 
Back
Top