Add-in to Read from Public Folder

C

Chris McHenry

I have an C# VSTO add-in (running on both OL 2003 and OL 2007 clients) that is reading a large number of items from a public folder on startup. To improve performance, I moved this operation to a background thread. This seems to be working on a large set of my user population, but there is one user where it is causing Outlook to intermittently hang on startup. This user has OL2003 SP3. The Outlook client hangs when updating the folders and downloading data leading me to think that its something to do with cache mode.

I've read several posts that say not to use the OOM on a background thread. However, for my add-in to load in a reasonable amount of time I see few other alternatives for my architecture. I also saw some talk on this forum about marshalling data between the background and foreground threads, but the slowness I'm experiencing is reading the data using the OOM. Putting that on the foreground thread would frustrate my users to no end. One idea I had is to move this operation "out of process" by running another executable from my add-in or installing a service with my addin that does this work. I suppose this could create additional conflicts in the OOM?

I was using Outlook Redemption RDO objects to do this work, but found that due to the public folder architecture at my client, Redemption was not properly reading and authenticating to the public folder server for users who didn't have a public folder store on the same server as their mail store. I tried to troubleshoot with the Exchange admin, but found that nothing we did would make it work. Switching to the OOM worked, now I have this strange, one-off problem.

Here is the thread start block of code:

initThread = new Thread(CompleteInit);
initThread.Priority = ThreadPriority.Lowest;
initThread.IsBackground = true;
initThread.Start();

Here is the method called from CompleteInit where the code seems to hang:

public DataTable LoadDataTableFromConfig(string tableName)
{
ErrorLog.WriteLog(null, "ExchangeServer", "LoadDataTableFromConfig: Begin");
DataTable lDtResult = null;
try
{
ErrorLog.WriteLog(null, "ExchangeServer", "LoadDataTableFromConfig: Loading Public Folder: " + tableName);

if (tableName == "tblFileplanConfig")
return GetFilePlan();

lDtResult = SelectDatastructure(tableName);

OOMFolder folder = GetPublicFolder(@"ControlCenter\" + tableName);
if (folder != null)
{
ErrorLog.WriteLog(null, "ExchangeServer",
"LoadDataTableFromConfig: Found Public Folder - " + folder.FullFolderPath);

Items mailItems = folder.Items;
foreach (MailItem item in mailItems)
{
ErrorLog.WriteLog(null, "ExchangeServer", "GetFilePlan(): bailOut: " + bailOut);
if (bailOut)
return null;

ErrorLog.WriteLog(null, "ExchangeServer", "LoadDataTableFromConfig: Reading item");
if (item != null)
{
//string comment = (string)GetPropertyHelper(item, "comment");
SafeMailItem safeMailItem = new SafeMailItem();
safeMailItem.Item = item;
const int prComment = 0x3004001E;
string comment = (string)safeMailItem.get_Fields(prComment);
ErrorLog.WriteLog(null, "ExchangeServer", "LoadDataTableFromConfig - Found item:" + comment);
string[] dataElements = comment.Split(new char[] { '|' });

DataRow dr = lDtResult.NewRow();
for (int i = 0; i < lDtResult.Columns.Count; i++)
{
try
{
dr = GetValueFromArray(dataElements, lDtResult.Columns.ColumnName);
}
catch (Exception ex)
{
ErrorLog.WriteLog(ex, "ExchangeServer", "GetProperties:");
}
}
lDtResult.Rows.Add(dr);

}
}

}
}
catch (Exception ex)
{
ErrorLog.WriteLog(ex, "ExchangeServer", "LoadDataTableFromConfig:");
throw;
}

ErrorLog.WriteLog(null, "ExchangeServer", "LoadDataTableFromConfig: Complete");
return lDtResult;
}



Does anyone have any ideas for me as to how to work around this limitation of Outlook?

EggHeadCafe - Software Developer Portal of Choice
FLASH: Fix for Windows Vista
http://www.eggheadcafe.com/tutorial...a8-3712c676eb02/flash-fix-for-windows-vi.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top