Find Related Messages in Outlook 2003 in VSTO C#

  • Thread starter Thread starter PGS123
  • Start date Start date
P

PGS123

Hi,

I have a sample code here which simply looks for the same email subject and
returns the total of number messages located in a folder. But this code took
noticeably longer time to execute compare to the good old Outlook's "Find All
/ Related Messages" feature. This Outlook's feature returns a list in an
instant without delay while this sample code took at least 2 or more seconds
to return just a number.

==================== begin ==================
private int FindEmailsWithSameSubject(string EmailSubject)
{
int MessageFound = 0;

// The following two variables are declared
// private Outlook.Application App;
// private Outlook.Explorer CurrentExplorer;
// and defined globally in the main class:
// App = new Outlook.Application();
// CurrentExplorer = App.ActiveExplorer();

Outlook.MAPIFolder SelectedFolder = CurrentExplorer.CurrentFolder;

foreach (Object SelectedObject in SelectedFolder.Items)
{
// Only work on messages which are email items.
if (SelectedObject is Outlook.MailItem)
{
Outlook.MailItem MailItem = SelectedObject as Outlook.MailItem;
if (EmailSubject == MailItem.Subject)
{
++MessageFound;
}
}
}
return MessageFound;
}
==================== end ==================

This code is executed on an inbox with just 190 messages. Questions:

1) Why this code take a longer time to run?
2) Is there a better way to find all related messages?

Thanks a lot.
Robin
 
Hi Robin,

We don't support the coding related issue. Hope anyone else here will help you!

In addition, for assistance with this coding issue, you can also post it in the MSDN newsgroups for peer experiences and recommendations. I
have provided link as below:

http://msdn.microsoft.com/newsgroups/default.asp

Thanks for your understanding.

Regards,

Emily Lin

Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
====================================================
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
Hi Emily,

Ok. Thanks for the info. I also found out another place
(microsoft.public.outlook.program_addins) to try while reading some other
postings earlier. I will repost this there but if anyone here can shed some
light on this matter it will be greatly appreciated.

Thanks again.
Robin
 
Hi Robin,

Thanks for your understanding. Hope someone else will help on it!

Have a nice day!

Emily Lin,
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
======================================================
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
Hi FH,

Thanks for your kind info. Appreciate it. Will certainly give your
referenced site a try if I don't get any response from
microsoft.public.outlook.program_addins.

Robin
 
Back
Top