G
Guest
When running Outlook 2007 in cached mode, the
ResultsEvents_ItemAddEventHandler never seems to work. So in the sample
below, "mySearchResults_ItemAdd" never gets called when a "read" item is
added to the search results (filter for AdvancedSearch is
urn:schemas:httpmail:read = 1).
This works find when cached mode is unchecked in Outlook account settings.
Any ideas?
Example Code:
using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace OutlookAddIn
{
public partial class ThisAddIn
{
private Outlook.Application applicationObject;
private Outlook.Results mySearchResults;
private const string SearchResultsTag =
"READ_MESSAGE_SEARCH_RESULTS_TEST";
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
ThisAddIn thisAddIn = (ThisAddIn)sender;
applicationObject = (Outlook.Application)thisAddIn.Application;
string strFolderList = "Inbox";
string strFilter = "urn:schemas:httpmail:read = 1";
((Outlook.ApplicationEvents_11_Event)applicationObject).AdvancedSearchComplete +=
new
ApplicationEvents_11_AdvancedSearchCompleteEventHandler(applicationObject_AdvancedSearchComplete);
applicationObject.AdvancedSearch(strFolderList, strFilter, true,
SearchResultsTag);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
private void applicationObject_AdvancedSearchComplete(Search
SearchObject)
{
if (SearchObject.Tag == SearchResultsTag)
{
this.mySearchResults = SearchObject.Results;
this.mySearchResults.ItemAdd += new
ResultsEvents_ItemAddEventHandler(mySearchResults_ItemAdd);
}
}
private void mySearchResults_ItemAdd(object Item)
{
// this never gets called when outlook 2007 runs in cached mode
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
ResultsEvents_ItemAddEventHandler never seems to work. So in the sample
below, "mySearchResults_ItemAdd" never gets called when a "read" item is
added to the search results (filter for AdvancedSearch is
urn:schemas:httpmail:read = 1).
This works find when cached mode is unchecked in Outlook account settings.
Any ideas?
Example Code:
using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace OutlookAddIn
{
public partial class ThisAddIn
{
private Outlook.Application applicationObject;
private Outlook.Results mySearchResults;
private const string SearchResultsTag =
"READ_MESSAGE_SEARCH_RESULTS_TEST";
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
ThisAddIn thisAddIn = (ThisAddIn)sender;
applicationObject = (Outlook.Application)thisAddIn.Application;
string strFolderList = "Inbox";
string strFilter = "urn:schemas:httpmail:read = 1";
((Outlook.ApplicationEvents_11_Event)applicationObject).AdvancedSearchComplete +=
new
ApplicationEvents_11_AdvancedSearchCompleteEventHandler(applicationObject_AdvancedSearchComplete);
applicationObject.AdvancedSearch(strFolderList, strFilter, true,
SearchResultsTag);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
private void applicationObject_AdvancedSearchComplete(Search
SearchObject)
{
if (SearchObject.Tag == SearchResultsTag)
{
this.mySearchResults = SearchObject.Results;
this.mySearchResults.ItemAdd += new
ResultsEvents_ItemAddEventHandler(mySearchResults_ItemAdd);
}
}
private void mySearchResults_ItemAdd(object Item)
{
// this never gets called when outlook 2007 runs in cached mode
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}