A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Using Restrict method to select emails



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 25th 07, 06:15 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Jerry West
external usenet poster
 
Posts: 15
Default Using Restrict method to select emails

I'm trying to use the .Restrict method to select emails within the Inbox:

sSearch$ = "[From] = 'Jake Parlance'"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderInbox)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

This works just fine if the email in question has in its From field the name
Jake Parlance. But if I only know Jake Parlance's email address then it
would fail:

sSearch$ = "[From] = '"

I assume it fails because the email address is "resolved" to the person's
actual name. I'd like to be able to search using only the email address
without needing to know the person's name. Is there a way to do this? I
tried:

sSearch$ = "[E-mail] = '"

This did not work because I assume "[E-mail]" is not a "keyword"? Is it
possible to search using email only?

Also, where does one find a list of all the "keywords", like "[From]"?

Thanks!

JW


  #2  
Old April 25th 07, 06:28 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Using Restrict method to select emails

Use the SenderEmailAddress property in your restriction.

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

"Jerry West" wrote in message
...
I'm trying to use the .Restrict method to select emails within the Inbox:

sSearch$ = "[From] = 'Jake Parlance'"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderInbox)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

This works just fine if the email in question has in its From field the
name Jake Parlance. But if I only know Jake Parlance's email address then
it would fail:

sSearch$ = "[From] = '"

I assume it fails because the email address is "resolved" to the person's
actual name. I'd like to be able to search using only the email address
without needing to know the person's name. Is there a way to do this? I
tried:

sSearch$ = "[E-mail] = '"

This did not work because I assume "[E-mail]" is not a "keyword"? Is it
possible to search using email only?

Also, where does one find a list of all the "keywords", like "[From]"?

Thanks!

JW



  #3  
Old April 25th 07, 07:01 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Jerry West
external usenet poster
 
Posts: 15
Default Using Restrict method to select emails

Thank you for your answer. Where does one find a list of these "keywords"?
For, example SenderEmailAddress or From? Is there a list of these keywords
anywhere?

Is "To" a valid keyword? I am trying to select emails based on who the email
was sent to from within the Sent Items folder:

sSearch$ = "[To] = '"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderSentMa il)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

The objItemsCollection.Count property is always 0. So I'm wondering if "To"
is a keyword? If not, what should I be using and where does one find these
keywords?

Thanks,

JW

"Dmitry Streblechenko" wrote in message
...
Use the SenderEmailAddress property in your restriction.

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

"Jerry West" wrote in message
...
I'm trying to use the .Restrict method to select emails within the Inbox:

sSearch$ = "[From] = 'Jake Parlance'"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderInbox)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

This works just fine if the email in question has in its From field the
name Jake Parlance. But if I only know Jake Parlance's email address then
it would fail:

sSearch$ = "[From] = '"

I assume it fails because the email address is "resolved" to the person's
actual name. I'd like to be able to search using only the email address
without needing to know the person's name. Is there a way to do this? I
tried:

sSearch$ = "[E-mail] = '"

This did not work because I assume "[E-mail]" is not a "keyword"? Is it
possible to search using email only?

Also, where does one find a list of all the "keywords", like "[From]"?

Thanks!

JW





  #4  
Old April 25th 07, 07:33 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Using Restrict method to select emails

It is just an Outlook property name, as in MailItem.SenderEmailAddress. Have
you actually tried it?
To property in most cases includes both names and addresses and corresponds
to the PR_DISPLAY_TO MAPI property (look at messages with MFCMAPI or
OutlookSpy), so your restriction won't match any messages.

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

"Jerry West" wrote in message
...
Thank you for your answer. Where does one find a list of these "keywords"?
For, example SenderEmailAddress or From? Is there a list of these keywords
anywhere?

Is "To" a valid keyword? I am trying to select emails based on who the
email was sent to from within the Sent Items folder:

sSearch$ = "[To] = '"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderSentMa il)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

The objItemsCollection.Count property is always 0. So I'm wondering if
"To" is a keyword? If not, what should I be using and where does one find
these keywords?

Thanks,

JW

"Dmitry Streblechenko" wrote in message
...
Use the SenderEmailAddress property in your restriction.

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

"Jerry West" wrote in message
...
I'm trying to use the .Restrict method to select emails within the
Inbox:

sSearch$ = "[From] = 'Jake Parlance'"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderInbox)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

This works just fine if the email in question has in its From field the
name Jake Parlance. But if I only know Jake Parlance's email address
then it would fail:

sSearch$ = "[From] = '"

I assume it fails because the email address is "resolved" to the
person's actual name. I'd like to be able to search using only the email
address without needing to know the person's name. Is there a way to do
this? I tried:

sSearch$ = "[E-mail] = '"

This did not work because I assume "[E-mail]" is not a "keyword"? Is it
possible to search using email only?

Also, where does one find a list of all the "keywords", like "[From]"?

Thanks!

JW







  #5  
Old April 25th 07, 07:42 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Jerry West
external usenet poster
 
Posts: 15
Default Using Restrict method to select emails

as in MailItem.SenderEmailAddress. Have you actually tried it?

Yes, it worked great.

To property in most cases includes both names and addresses


So then the code I show should work, right? I checked the email and I see
that the "To" field shows the email address versus the actual name:

sSearch$ = "[To] = '"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderSentMa il)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

Is the above not valid for selecting an email address of
within the Sent Items folder? If not, what is the
proper way to do it? Can you show an example? I have tried the above on my
system and it does not locate the email address in the Sent Items folder
that I know is there.

Thanks,

JW


"Dmitry Streblechenko" wrote in message
...
It is just an Outlook property name, as in MailItem.SenderEmailAddress.
Have you actually tried it?
To property in most cases includes both names and addresses and
corresponds to the PR_DISPLAY_TO MAPI property (look at messages with
MFCMAPI or OutlookSpy), so your restriction won't match any messages.

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

"Jerry West" wrote in message
...
Thank you for your answer. Where does one find a list of these
"keywords"? For, example SenderEmailAddress or From? Is there a list of
these keywords anywhere?

Is "To" a valid keyword? I am trying to select emails based on who the
email was sent to from within the Sent Items folder:

sSearch$ = "[To] = '"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderSentMa il)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

The objItemsCollection.Count property is always 0. So I'm wondering if
"To" is a keyword? If not, what should I be using and where does one find
these keywords?

Thanks,

JW

"Dmitry Streblechenko" wrote in message
...
Use the SenderEmailAddress property in your restriction.

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

"Jerry West" wrote in message
...
I'm trying to use the .Restrict method to select emails within the
Inbox:

sSearch$ = "[From] = 'Jake Parlance'"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderInbox)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

This works just fine if the email in question has in its From field the
name Jake Parlance. But if I only know Jake Parlance's email address
then it would fail:

sSearch$ = "[From] = '"

I assume it fails because the email address is "resolved" to the
person's actual name. I'd like to be able to search using only the
email address without needing to know the person's name. Is there a way
to do this? I tried:

sSearch$ = "[E-mail] = '"

This did not work because I assume "[E-mail]" is not a "keyword"? Is it
possible to search using email only?

Also, where does one find a list of all the "keywords", like "[From]"?

Thanks!

JW









  #6  
Old April 25th 07, 07:55 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Using Restrict method to select emails

No, [To] won't work since you are not including the name (it may or rmay not
be there)- look at messages with OutlookSpy. most likely To (and
PR_DISPLAY_TO MAPI) will be something like "Jerry West" or "Jerry West
"
Do use SenderEmailAddress.

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

"Jerry West" wrote in message
...
as in MailItem.SenderEmailAddress. Have you actually tried it?


Yes, it worked great.

To property in most cases includes both names and addresses


So then the code I show should work, right? I checked the email and I see
that the "To" field shows the email address versus the actual name:

sSearch$ = "[To] = '"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderSentMa il)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

Is the above not valid for selecting an email address of
within the Sent Items folder? If not, what is the
proper way to do it? Can you show an example? I have tried the above on my
system and it does not locate the email address in the Sent Items folder
that I know is there.

Thanks,

JW


"Dmitry Streblechenko" wrote in message
...
It is just an Outlook property name, as in MailItem.SenderEmailAddress.
Have you actually tried it?
To property in most cases includes both names and addresses and
corresponds to the PR_DISPLAY_TO MAPI property (look at messages with
MFCMAPI or OutlookSpy), so your restriction won't match any messages.

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

"Jerry West" wrote in message
...
Thank you for your answer. Where does one find a list of these
"keywords"? For, example SenderEmailAddress or From? Is there a list of
these keywords anywhere?

Is "To" a valid keyword? I am trying to select emails based on who the
email was sent to from within the Sent Items folder:

sSearch$ = "[To] = '"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderSentMa il)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

The objItemsCollection.Count property is always 0. So I'm wondering if
"To" is a keyword? If not, what should I be using and where does one
find these keywords?

Thanks,

JW

"Dmitry Streblechenko" wrote in message
...
Use the SenderEmailAddress property in your restriction.

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

"Jerry West" wrote in message
...
I'm trying to use the .Restrict method to select emails within the
Inbox:

sSearch$ = "[From] = 'Jake Parlance'"

Set fldFolder = CRM.O.AppNameSpace.GetDefaultFolder(olFolderInbox)

Set objItemsCollection = fldFolder.Items.Restrict(sSearch$)

This works just fine if the email in question has in its From field
the name Jake Parlance. But if I only know Jake Parlance's email
address then it would fail:

sSearch$ = "[From] = '"

I assume it fails because the email address is "resolved" to the
person's actual name. I'd like to be able to search using only the
email address without needing to know the person's name. Is there a
way to do this? I tried:

sSearch$ = "[E-mail] = '"

This did not work because I assume "[E-mail]" is not a "keyword"? Is
it possible to search using email only?

Also, where does one find a list of all the "keywords", like "[From]"?

Thanks!

JW











 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Restrict Dynamic MON205 Add-ins for Outlook 2 April 4th 07 04:34 PM
Restrict method problem Mike Epp Outlook and VBA 2 April 7th 06 07:03 PM
Restrict Method DNW emanson Outlook and VBA 14 March 28th 06 05:47 AM
2 emails in one profile, how to select witch to use Roger Payne Outlook - Installation 2 February 26th 06 12:17 PM
Restrict jim Add-ins for Outlook 2 January 13th 06 08:14 PM


All times are GMT +1. The time now is 12:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.