![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hello all,
I'm developing an Outlook Addin... I encounter a problem that when my addin perform simple functionality which is looping through all folders, then when the user work on Outlook move messages from the inbox to Deleted Items folder, the Deleted Items folder still empty till you restart the outlook. In my code, I loop through all folders and get Items an do some process on them. For testing this problem I removed looping into items and processing and the problem still. Finally I found that the problem in "pFolder-get_Items" which when I call, the problem found, and if I removed this statement, the problem fly... In my code below, I don't do anything with the _ItemsPtr !!!!! Where is the problem?!! What I've missed?!! Here is my code: ////////////////////////////////////////////////////////////// int MyClass::Start( ) { m_nCount = 0; Outlook::_NameSpacePtr pMapi = NULL; pMapi = m_spApp-GetNamespace( _bstr_t( "MAPI" ) ); if( NULL == pMapi ) { return 0; } HRESULT hr; _FoldersPtr pFoldersCollection = NULL; hr = pMapi-get_Folders( & pFoldersCollection ); if( FAILED( hr ) ) { pMapi-Release( ); pMapi = NULL; return 0; } MAPIFolderPtr pFolder = NULL; long lFoldersCount = pFoldersCollection-GetCount( ); pFolder = pFoldersCollection-GetFirst( ); for( long lIndex = 0; lIndex lFoldersCount; lIndex++ ) { ReadFolder( pFolder ); // release... pFolder-Release( ); pFolder = NULL; pFolder = pFoldersCollection-GetNext( ); } // release... pFoldersCollection-Release( ); pFoldersCollection = NULL; pMapi-Release( ); pMapi = NULL; return 1; } int MyClass::ReadFolder( MAPIFolderPtr pFolder ) { _ItemsPtr pItems = NULL; HRESULT hr; hr = pFolder-get_Items( & pItems ); // Here is the problem if( FAILED( hr ) ) { return 0; } // release... pItems-Release( ); pItems = NULL; _FoldersPtr pFoldersCollection = NULL; hr = pFolder-get_Folders( & pFoldersCollection ); if( FAILED( hr ) ) { return 0; } long lFoldersCount = pFoldersCollection-GetCount( ); if( lFoldersCount 0 ) { MAPIFolderPtr pInnerFolder = pFoldersCollection-GetFirst( ); while( pInnerFolder ) { ReadFolder( pInnerFolder ); // release... pInnerFolder-Release( ); pInnerFolder = NULL; pInnerFolder = pFoldersCollection-GetNext( ); } } // release... pFoldersCollection-Release( ); pFoldersCollection = NULL; return 1; } ////////////////////////////////////////////////////////////// |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleted items not updated!!! | MON205 | Outlook - General Queries | 0 | April 11th 07 12:44 PM |
Remove from server when deleted from 'Deleted Items' - Archiving? | [email protected] | Outlook - General Queries | 1 | August 2nd 06 06:34 PM |
Auto Empty Deleted Items on Exit OR after X days or X Items accumulated? | JDJ | Outlook - General Queries | 2 | May 30th 06 10:48 PM |
Inbox, Sent Items & Outbox in Deleted Items in Outlook 2003 & OWA with Exchange | splounx | Outlook - General Queries | 1 | February 17th 06 02:22 AM |
Recover deleted messages after emptying deleted items folder | Gail | Outlook Express | 2 | January 30th 06 05:18 PM |