S
sb
Hello,
I am developing an Outlook add-in using VSTO in VS2008, using .Net 2.0 and
Outlook 2003. I have a bit of functionality that executes an advancedsearch
and catches the AdvancedSearchComplete event. However, when the results come
back, the Search parameter passed to the event handler does not appear to be
ready for use.
The search:
sFilter = "\"urn:schemas:httpmail:subject\" LIKE '%subject
string%' AND ";
sFilter += "\"urn:schemas:httpmail:textdescription\" LIKE '%text
description%'";
//Execute the search
try
{
Outlook.Application a = m_addIn.Application;
sScope = "'\\\\valid folder\\'";
a.AdvancedSearch(sScope, sFilter, true, "Tag");
}
The event handler:
private void m_outlook_AdvancedSearchComplete(Outlook.Search
searchObj)
{
//MessageBox.Show(searchObj.Results.Count.ToString());
for (int i = 1; i <= searchObj.Results.Count; i++)
{
//do stuff
}
Everything seems to be working fine, the search is successful and the
AdvancedSearchComplete event fires when it is done. However, when
AdvancedSearchComplete is fired as expected, searchObj.Results.Count is
ALWAYS zero. But... If that MessageBox.Show line is uncommented, it always
displays '0', but then the subsequent calls to searchObj in the for... and
beyond correctly reflect the search Results. I have tried a Thread.Sleep()
call in there to no avail.
Thoughts? I thought the results were guaranteed to be ready when this event
fires. Is there some setting I am missing somewhere?
thanks
I am developing an Outlook add-in using VSTO in VS2008, using .Net 2.0 and
Outlook 2003. I have a bit of functionality that executes an advancedsearch
and catches the AdvancedSearchComplete event. However, when the results come
back, the Search parameter passed to the event handler does not appear to be
ready for use.
The search:
sFilter = "\"urn:schemas:httpmail:subject\" LIKE '%subject
string%' AND ";
sFilter += "\"urn:schemas:httpmail:textdescription\" LIKE '%text
description%'";
//Execute the search
try
{
Outlook.Application a = m_addIn.Application;
sScope = "'\\\\valid folder\\'";
a.AdvancedSearch(sScope, sFilter, true, "Tag");
}
The event handler:
private void m_outlook_AdvancedSearchComplete(Outlook.Search
searchObj)
{
//MessageBox.Show(searchObj.Results.Count.ToString());
for (int i = 1; i <= searchObj.Results.Count; i++)
{
//do stuff
}
Everything seems to be working fine, the search is successful and the
AdvancedSearchComplete event fires when it is done. However, when
AdvancedSearchComplete is fired as expected, searchObj.Results.Count is
ALWAYS zero. But... If that MessageBox.Show line is uncommented, it always
displays '0', but then the subsequent calls to searchObj in the for... and
beyond correctly reflect the search Results. I have tried a Thread.Sleep()
call in there to no avail.
Thoughts? I thought the results were guaranteed to be ready when this event
fires. Is there some setting I am missing somewhere?
thanks