>I can look at the message in the VB6 IDE. I see that the .To property reads
>jake.fake@bademail.com. No name is included.
[quoted text clipped - 132 lines]
>>>>>>>
>>>>>>> JW
> Can you run it from OutlookSpy? Select a folder where you want to search,
> click the "Script Editor" button on the OutlookSpy toolbar, paste the
> script, modify the condition appropriately, click Run.
set Folder = Application.ActiveExplorer.CurrentFolder
set RestrItems = Folder.Items.Restrict("[To] = 'jake.fake@bademail.com'")
MsgBox RestrItems.Count
Not sure how this was going to be different than what I was doing in VB but
I did try it. As in VB, .Count is zero. It fails to return the email which
has in its To property the email address of jake.fake@bademail.com.
If the To property of the email shows as jake.fake@bademail.com and the VB6
IDE also shows that is what the To property holds then shouldn't my code
work?
set Folder = Application.ActiveExplorer.CurrentFolder
set RestrItems = Folder.Items.Restrict("[To] = 'jake.fake@bademail.com'")
MsgBox RestrItems.Count
I have placed 5 emails in my Sent Items folder. I tried searching for each
one of them. I modified my restrict statement to reflect the value of the To
field whether it was an actual email address or the "resolved" name. In no
case did the search return a hit. There must be some explanation for this. I
am using the above code. I can see within the debug window of the VB IDE
that the Sent Items folder has the emails I am searching for in it --yet if
fails to return them. What could I be doing wrong? Is there another property
I could search upon that would yield the same data as the To property?
JW
JW
>I have no problem running the following script
>
[quoted text clipped - 148 lines]
>>>>>>>>
>>>>>>>> JW
Jerry West - 25 Apr 2007 22:20 GMT
Further testing shows that the problem on exists with the Sent Items folder.
I can search using the To and From fields without issue on folders other
than the Sent Items folder. The search always fails when searching this
folder in particular. Is there some reason why this is? Is there some
condition to searching the Sent Items folder I'm not aware of?
Any help appreciated.
JW
>> Can you run it from OutlookSpy? Select a folder where you want to search,
>> click the "Script Editor" button on the OutlookSpy toolbar, paste the
[quoted text clipped - 183 lines]
>>>>>>>>>
>>>>>>>>> JW
Dmitry Streblechenko - 25 Apr 2007 23:54 GMT
"which has in its To property the email address of jake.fake@bademail.com" -
this is not what your code does, your code restricts on the *exact* match
(which is different from "contains").
Are you sure there are no other characters in the To property? Such as
single quotes? Look at a matching message with OutlookSpy (click IMessage
button). What do you see in PR_DISPLAY_TO?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
>> Can you run it from OutlookSpy? Select a folder where you want to search,
>> click the "Script Editor" button on the OutlookSpy toolbar, paste the
[quoted text clipped - 183 lines]
>>>>>>>>>
>>>>>>>>> JW
Jerry West - 26 Apr 2007 00:14 GMT
The PR_DISPLAY_TO field shows: 'jake.fake@bademail.com'
So it shows the single quote at the beginning of the name and at the end of
the name. So is this not an exact match to that?:
set RestrItems = Folder.Items.Restrict("[To] = 'jake.fake@bademail.com'")
I find it worthy to note that this issue on occurs with the Sent Items
folder. I have no trouble on the other folders I tried. There has to be some
significance to this clue.
JW
> "which has in its To property the email address of
> jake.fake@bademail.com" - this is not what your code does, your code
[quoted text clipped - 197 lines]
>>>>>>>>>>
>>>>>>>>>> JW
Dmitry Streblechenko - 26 Apr 2007 00:54 GMT
Yep, single quotes are not any different from any other character; you must
include them in your restriction.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> The PR_DISPLAY_TO field shows: 'jake.fake@bademail.com'
>
[quoted text clipped - 213 lines]
>>>>>>>>>>>
>>>>>>>>>>> JW
Jerry West - 26 Apr 2007 01:16 GMT
I need to add an additional ' character? So you are saying I need to change
the search string to look like this:
set RestrItems = Folder.Items.Restrict("[To] = ''jake.fake@bademail.com''")
When I try that I get an error. Must the ' character be escaped somehow?
JW
> Yep, single quotes are not any different from any other character; you
> must include them in your restriction.
[quoted text clipped - 222 lines]
>>>>>>>>>>>>
>>>>>>>>>>>> JW
Dmitry Streblechenko - 26 Apr 2007 01:33 GMT
Close :-) You need to include ' 3 times...
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
>I need to add an additional ' character? So you are saying I need to change
>the search string to look like this:
[quoted text clipped - 233 lines]
>>>>>>>>>>>>>
>>>>>>>>>>>>> JW
Jerry West - 26 Apr 2007 02:12 GMT
I'll be damned, it worked.
Adding the extra ' character was what was missing. So my next question is;
is there another property that contains an unmodified recipient address? I'm
concerned about needing to make two different search calls just to check a
single email address; one with the extra ' characters and one without. This
appears necessary since sometimes the PR_DISPLAY_TO field will show the
extra ' characters and sometimes it isn't there.
JW
> Close :-) You need to include ' 3 times...
>
[quoted text clipped - 241 lines]
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> JW
Dmitry Streblechenko - 26 Apr 2007 17:48 GMT
On the Extended MAPI level, sure, just create a restriction on
PR_MESSAGE_RECIPIENTS with subrestriction on PR_EMAIL_ADDRESS being an exact
match of the specified value.
I don't think you can do that on the OOM level (but I don't deal with
restrictions in OOM that much).
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> I'll be damned, it worked.
>
[quoted text clipped - 252 lines]
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> JW