SenderName problem and restrict performance

P

piyush

Hello,
I am writing a simple library in C# to display the name of the person
from the contact given the phone number (either business, home, mobile
etc). I also want
to then display any read and unread mails from that person.
I first go to contact and fetch the persons name depending on the
phone number supplied - say "Bill Gates".

I am facing these problems :

My current code uses Restrict (sFilter) where say

sFilter = "[SenderName] = 'Bill Gates'".

This works only if the SenderName is Bill Gates and not if say the
email comes
like Bill Gates (IT) or Bill Gates (HR).

The problem arises as people might use multiple emails and have
multiple display names like

"Bill Gates"
"Bill J. Gates"
"Gates, Bill"
"Gates, Bill (IT)"

While I can use multiple restricts for checking each condition, the
(IT) or (HR) conditions seem not solvable.

My question is whether we can use some variable strings in SenderName
like say I can check for opening and closing paranthesis in the
SenderName and use wild card characters to try to match only the first
parts :

sFilter = "[SenderName] = 'Bill Gates (??)' for handling cases like
Bill Gates (IT) and Bill Gates (HR) etc.

My second question is about performance. This piece of code would be
used in a large firm and hence Exchange server performance is very
critical.

I've heard using Restrict reduces the performance a lot - is there a
better way for finding mails from a particular person ?

Also, would using multiple restricts further decrease performance as
compared to just one restrict ?

Thanks in advance !
Piyush
 
S

Sue Mosher [MVP-Outlook]

No, Restrict and Find do not support wildcards. If you are planning to
support only Outlook 2002 or later, you can use its AdvancedSearch feature
to perform a search with SQL-like syntax that does support a %Like%
operator.

I don't know whether AdvancedSearch caches a restriction on the folder like
Restrict does. You might need to do some testing.
 
D

Dmitry Streblechenko \(MVP\)

AFAIK AdvancedSearch creates a temporary search folder which is deleted when
it is completely dereferenced.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Sue Mosher said:
No, Restrict and Find do not support wildcards. If you are planning to
support only Outlook 2002 or later, you can use its AdvancedSearch feature
to perform a search with SQL-like syntax that does support a %Like%
operator.

I don't know whether AdvancedSearch caches a restriction on the folder like
Restrict does. You might need to do some testing.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



piyush said:
Hello,
I am writing a simple library in C# to display the name of the person
from the contact given the phone number (either business, home, mobile
etc). I also want
to then display any read and unread mails from that person.
I first go to contact and fetch the persons name depending on the
phone number supplied - say "Bill Gates".

I am facing these problems :

My current code uses Restrict (sFilter) where say

sFilter = "[SenderName] = 'Bill Gates'".

This works only if the SenderName is Bill Gates and not if say the
email comes
like Bill Gates (IT) or Bill Gates (HR).

The problem arises as people might use multiple emails and have
multiple display names like

"Bill Gates"
"Bill J. Gates"
"Gates, Bill"
"Gates, Bill (IT)"

While I can use multiple restricts for checking each condition, the
(IT) or (HR) conditions seem not solvable.

My question is whether we can use some variable strings in SenderName
like say I can check for opening and closing paranthesis in the
SenderName and use wild card characters to try to match only the first
parts :

sFilter = "[SenderName] = 'Bill Gates (??)' for handling cases like
Bill Gates (IT) and Bill Gates (HR) etc.

My second question is about performance. This piece of code would be
used in a large firm and hence Exchange server performance is very
critical.

I've heard using Restrict reduces the performance a lot - is there a
better way for finding mails from a particular person ?

Also, would using multiple restricts further decrease performance as
compared to just one restrict ?

Thanks in advance !
Piyush
 
P

piyush

Thanks Ms. Mosher for the reply but I have more problems now.

I am trying to use AdvancedSearch but facing problems with C#.

Where should the AdvancedSearchComplete code be put ? Should it be a
function
in itself ? If so, what should be its name (in VBA, I saw
Application_AdvancedSearchComplete or
outlookobj_AdvancedSearchComplete in Randy Bryne's book).

Also, does urn:schemas:inbox:SenderName exist for me to search on
SenderName?

My code is as follows :

class blah {

private Outlook.ApplicationClass ola ;
private Outlook.Namespace olns

blah() //constructor
{
// all this constructor work is perfect
olns = ola.GetNamespace ;
.... (all these things seem to be fine)
}

public void func1()
{
Outlook.Search olsearch;
ola.Application.AdvancedSearch ("Inbox", "urn:schemas:inbox:SenderName
LIKE '%Bill%'", false, "complete")
}

public void AdvancedSearchComplete(Outlook.Search olsearch)
{
olresults = olsearch.Results;
for (int i = 1 ; i < olresults.Count ; i++)
{
Outlook._MailItem tempItem = (Outlook._MailItem)olresults.Item (i);
Console.Writeline (tempItem.Subject);
}
}//AdvancedSearchComplete
}//class

Obviously this doesnt work.

A different way to solve my problem is :

I have defined 3 search filters that cover all the cases matching the
SenderName (hence no need of wild characters and hence no need of
AdvancedSearch).

The problem is each of them is a different Restrict and hence each of
them is a differnet Items collection (ie)

"Bill Gates" returns results (in some random order apparently) in
colitems1
"Gates, Bill" returns results (in some random order apparently) in
colitems2

What I want to do is to sort the results and display the mails (from
either of the display names). For that I would need to have all the
items in a single collection (to sort them).

Any comments are highly appreciated.

Thanks !
Piyush



Sue Mosher said:
No, Restrict and Find do not support wildcards. If you are planning to
support only Outlook 2002 or later, you can use its AdvancedSearch feature
to perform a search with SQL-like syntax that does support a %Like%
operator.

I don't know whether AdvancedSearch caches a restriction on the folder like
Restrict does. You might need to do some testing.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



piyush said:
Hello,
I am writing a simple library in C# to display the name of the person
from the contact given the phone number (either business, home, mobile
etc). I also want
to then display any read and unread mails from that person.
I first go to contact and fetch the persons name depending on the
phone number supplied - say "Bill Gates".

I am facing these problems :

My current code uses Restrict (sFilter) where say

sFilter = "[SenderName] = 'Bill Gates'".

This works only if the SenderName is Bill Gates and not if say the
email comes
like Bill Gates (IT) or Bill Gates (HR).

The problem arises as people might use multiple emails and have
multiple display names like

"Bill Gates"
"Bill J. Gates"
"Gates, Bill"
"Gates, Bill (IT)"

While I can use multiple restricts for checking each condition, the
(IT) or (HR) conditions seem not solvable.

My question is whether we can use some variable strings in SenderName
like say I can check for opening and closing paranthesis in the
SenderName and use wild card characters to try to match only the first
parts :

sFilter = "[SenderName] = 'Bill Gates (??)' for handling cases like
Bill Gates (IT) and Bill Gates (HR) etc.

My second question is about performance. This piece of code would be
used in a large firm and hence Exchange server performance is very
critical.

I've heard using Restrict reduces the performance a lot - is there a
better way for finding mails from a particular person ?

Also, would using multiple restricts further decrease performance as
compared to just one restrict ?

Thanks in advance !
Piyush
 
S

Sue Mosher [MVP-Outlook]

Excellent! So a much better solution than Find or Restrict, assuming the
project environment supports it.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Dmitry Streblechenko (MVP) said:
AFAIK AdvancedSearch creates a temporary search folder which is deleted when
it is completely dereferenced.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Sue Mosher said:
No, Restrict and Find do not support wildcards. If you are planning to
support only Outlook 2002 or later, you can use its AdvancedSearch feature
to perform a search with SQL-like syntax that does support a %Like%
operator.

I don't know whether AdvancedSearch caches a restriction on the folder like
Restrict does. You might need to do some testing.

piyush said:
Hello,
I am writing a simple library in C# to display the name of the person
from the contact given the phone number (either business, home, mobile
etc). I also want
to then display any read and unread mails from that person.
I first go to contact and fetch the persons name depending on the
phone number supplied - say "Bill Gates".

I am facing these problems :

My current code uses Restrict (sFilter) where say

sFilter = "[SenderName] = 'Bill Gates'".

This works only if the SenderName is Bill Gates and not if say the
email comes
like Bill Gates (IT) or Bill Gates (HR).

The problem arises as people might use multiple emails and have
multiple display names like

"Bill Gates"
"Bill J. Gates"
"Gates, Bill"
"Gates, Bill (IT)"

While I can use multiple restricts for checking each condition, the
(IT) or (HR) conditions seem not solvable.

My question is whether we can use some variable strings in SenderName
like say I can check for opening and closing paranthesis in the
SenderName and use wild card characters to try to match only the first
parts :

sFilter = "[SenderName] = 'Bill Gates (??)' for handling cases like
Bill Gates (IT) and Bill Gates (HR) etc.

My second question is about performance. This piece of code would be
used in a large firm and hence Exchange server performance is very
critical.

I've heard using Restrict reduces the performance a lot - is there a
better way for finding mails from a particular person ?

Also, would using multiple restricts further decrease performance as
compared to just one restrict ?

Thanks in advance !
Piyush
 
S

Sue Mosher [MVP-Outlook]

Sorry, but I don't speak C#. AdvancedSearchComplete is an event of the
Outlook.Application object, so it needs an event handler.

You can get a list of available known field schema names from
http://www.slipstick.com/files/schema.zip . The Exchange SDK probably has
others.

For your alternative approach, I imagine that it really depends on what you
want to do with the data. A custom collection or an array both might be good
solutions.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



piyush said:
Thanks Ms. Mosher for the reply but I have more problems now.

I am trying to use AdvancedSearch but facing problems with C#.

Where should the AdvancedSearchComplete code be put ? Should it be a
function
in itself ? If so, what should be its name (in VBA, I saw
Application_AdvancedSearchComplete or
outlookobj_AdvancedSearchComplete in Randy Bryne's book).

Also, does urn:schemas:inbox:SenderName exist for me to search on
SenderName?

My code is as follows :

class blah {

private Outlook.ApplicationClass ola ;
private Outlook.Namespace olns

blah() //constructor
{
// all this constructor work is perfect
olns = ola.GetNamespace ;
... (all these things seem to be fine)
}

public void func1()
{
Outlook.Search olsearch;
ola.Application.AdvancedSearch ("Inbox", "urn:schemas:inbox:SenderName
LIKE '%Bill%'", false, "complete")
}

public void AdvancedSearchComplete(Outlook.Search olsearch)
{
olresults = olsearch.Results;
for (int i = 1 ; i < olresults.Count ; i++)
{
Outlook._MailItem tempItem = (Outlook._MailItem)olresults.Item (i);
Console.Writeline (tempItem.Subject);
}
}//AdvancedSearchComplete
}//class

Obviously this doesnt work.

A different way to solve my problem is :

I have defined 3 search filters that cover all the cases matching the
SenderName (hence no need of wild characters and hence no need of
AdvancedSearch).

The problem is each of them is a different Restrict and hence each of
them is a differnet Items collection (ie)

"Bill Gates" returns results (in some random order apparently) in
colitems1
"Gates, Bill" returns results (in some random order apparently) in
colitems2

What I want to do is to sort the results and display the mails (from
either of the display names). For that I would need to have all the
items in a single collection (to sort them).

Any comments are highly appreciated.

Thanks !
Piyush



"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
No, Restrict and Find do not support wildcards. If you are planning to
support only Outlook 2002 or later, you can use its AdvancedSearch feature
to perform a search with SQL-like syntax that does support a %Like%
operator.

I don't know whether AdvancedSearch caches a restriction on the folder like
Restrict does. You might need to do some testing.


piyush said:
Hello,
I am writing a simple library in C# to display the name of the person
from the contact given the phone number (either business, home, mobile
etc). I also want
to then display any read and unread mails from that person.
I first go to contact and fetch the persons name depending on the
phone number supplied - say "Bill Gates".

I am facing these problems :

My current code uses Restrict (sFilter) where say

sFilter = "[SenderName] = 'Bill Gates'".

This works only if the SenderName is Bill Gates and not if say the
email comes
like Bill Gates (IT) or Bill Gates (HR).

The problem arises as people might use multiple emails and have
multiple display names like

"Bill Gates"
"Bill J. Gates"
"Gates, Bill"
"Gates, Bill (IT)"

While I can use multiple restricts for checking each condition, the
(IT) or (HR) conditions seem not solvable.

My question is whether we can use some variable strings in SenderName
like say I can check for opening and closing paranthesis in the
SenderName and use wild card characters to try to match only the first
parts :

sFilter = "[SenderName] = 'Bill Gates (??)' for handling cases like
Bill Gates (IT) and Bill Gates (HR) etc.

My second question is about performance. This piece of code would be
used in a large firm and hence Exchange server performance is very
critical.

I've heard using Restrict reduces the performance a lot - is there a
better way for finding mails from a particular person ?

Also, would using multiple restricts further decrease performance as
compared to just one restrict ?

Thanks in advance !
Piyush
 

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