2
280Z28
Using Outlook 2007
In response to a custom menu item being clicked, I have a BackgroundWorker
start processing messages in a MAPIFolder.
While it is in the following loop, I get messages from Outlook saying an
add-in (NOD32) has been disabled due to an out-of-memory condition, and to .
There are 731 items in the folder it is processing, and it appears to give
the error about ~200 in. The error appears in Outlook when I step over the
marked line. I've included many extra details in that comment.
int FixDatesForFolder( Outlook.MAPIFolder folder, bool subfolders )
{
// NOTE: problem occurs even if subfolders is false
int count = 0;
foreach ( object item in folder.Items )
{
if ( !(item is Outlook.MailItem) )
continue;
Outlook.MailItem mailItem = (Outlook.MailItem)item;
// check the date range
// ***********************
// Outlook shows error about NOD32 being disabled while trying to
step
// into the following line. When this if statement is commented out,
// no error is given, but this function won't be able to operate
properly
// without this check. Also, when this statement is commented out
**and I
// have subfolders set to true**, memory usage in Outlook grows so
it is
// using 190MB by the time this function returns from processing
around
// 25,000 items. Memory seems to be freed not when the function
returns,
// but rather when when I close Outlook. I have 2GB of memory, and
in the
// worst case at least 800MB was free according to task manager, so
I
// don't know why I'm seeing Out-Of-Memory errors.
if ( !IsDateInRange( mailItem.ReceivedTime ) )
continue;
// fix the received date
FixDatesForItem( mailItem );
count++;
} while ( enumerator.MoveNext( ) );
if ( subfolders )
{
foreach ( Outlook.MAPIFolder sub in folder.Folders )
{
count += FixDatesForFolder( sub, true );
}
}
return count;
}
bool IsDateInRange( DateTime date )
{
// These are private class variables declared as follows
// DateTime beginDate = new DateTime( 2006, 4, 30, 18, 0, 0 );
// DateTime endDate = new DateTime( 2006, 5, 1, 2, 0, 0 );
return (date >= beginDate) && (date <= endDate);
}
void FixDatesForItem( Outlook.MailItem item )
{
// empty for now
}
In response to a custom menu item being clicked, I have a BackgroundWorker
start processing messages in a MAPIFolder.
While it is in the following loop, I get messages from Outlook saying an
add-in (NOD32) has been disabled due to an out-of-memory condition, and to .
There are 731 items in the folder it is processing, and it appears to give
the error about ~200 in. The error appears in Outlook when I step over the
marked line. I've included many extra details in that comment.
int FixDatesForFolder( Outlook.MAPIFolder folder, bool subfolders )
{
// NOTE: problem occurs even if subfolders is false
int count = 0;
foreach ( object item in folder.Items )
{
if ( !(item is Outlook.MailItem) )
continue;
Outlook.MailItem mailItem = (Outlook.MailItem)item;
// check the date range
// ***********************
// Outlook shows error about NOD32 being disabled while trying to
step
// into the following line. When this if statement is commented out,
// no error is given, but this function won't be able to operate
properly
// without this check. Also, when this statement is commented out
**and I
// have subfolders set to true**, memory usage in Outlook grows so
it is
// using 190MB by the time this function returns from processing
around
// 25,000 items. Memory seems to be freed not when the function
returns,
// but rather when when I close Outlook. I have 2GB of memory, and
in the
// worst case at least 800MB was free according to task manager, so
I
// don't know why I'm seeing Out-Of-Memory errors.
if ( !IsDateInRange( mailItem.ReceivedTime ) )
continue;
// fix the received date
FixDatesForItem( mailItem );
count++;
} while ( enumerator.MoveNext( ) );
if ( subfolders )
{
foreach ( Outlook.MAPIFolder sub in folder.Folders )
{
count += FixDatesForFolder( sub, true );
}
}
return count;
}
bool IsDateInRange( DateTime date )
{
// These are private class variables declared as follows
// DateTime beginDate = new DateTime( 2006, 4, 30, 18, 0, 0 );
// DateTime endDate = new DateTime( 2006, 5, 1, 2, 0, 0 );
return (date >= beginDate) && (date <= endDate);
}
void FixDatesForItem( Outlook.MailItem item )
{
// empty for now
}