Home All Groups Group Topic Archive Search About
Author
29 Oct 2007 8:09 AM
PascalB
Hi,

Looking thru the help file and MSDN, I wasn't able to find an example to
find messages by flagstatus.
The only examples I found are looping thru the entire folder.

I need to find only certain mailitems who are not flagged, or the Flagicon
is Red.

For example, i need
Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")

I know it is possible to search certain mailitems by using "Advanced find",
but how do you do this by script?

Thanks in advance,

PascalB

Author
29 Oct 2007 12:02 PM
Sue Mosher [MVP-Outlook]
I always think it's a good idea to create the query string with a separate statement, so you can test the result:

    strFind = "[Flagstatus]=""&olNoFlag&"
    MsgBox strFind

In this case, that would give you a query string of

    [Flagstatus]="&olNoFlag&

which isn't going to find anything at all. First of all, FlagStatus is an enumerated property, not a string. Second, the & characters are used in your expression as string literals not concatenation operator. So, you're close, but not quite there. This would be the query expression that includes the actual value of olNoFlag:

    strFind = "[Flagstatus]=" & olNoFlag

To use AdvancedFind in a script, you'd need a loop with a timer to add a delay to allow the search to complete. I'd stick to Find and Restrict.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> Looking thru the help file and MSDN, I wasn't able to find an example to
> find messages by flagstatus.
> The only examples I found are looping thru the entire folder.
>
> I need to find only certain mailitems who are not flagged, or the Flagicon
> is Red.
>
> For example, i need
> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>
> I know it is possible to search certain mailitems by using "Advanced find",
> but how do you do this by script?
>
> Thanks in advance,
>
> PascalB
>
>
Author
29 Oct 2007 1:35 PM
PascalB
Hi,

Thanks for the reply, but I'll probably stick with the "for each" script I
already have to go thru all my items.

I know that the given example wasn't real VBA script, it was only mentioned
to clear out the problem.

Could this be done be a simple search and find; perhaps some kind of filter
or query!?

Cheers,
PascalB
-----------------



"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
I always think it's a good idea to create the query string with a separate
statement, so you can test the result:

    strFind = "[Flagstatus]=""&olNoFlag&"
    MsgBox strFind

In this case, that would give you a query string of

    [Flagstatus]="&olNoFlag&

which isn't going to find anything at all. First of all, FlagStatus is an
enumerated property, not a string. Second, the & characters are used in your
expression as string literals not concatenation operator. So, you're close,
but not quite there. This would be the query expression that includes the
actual value of olNoFlag:

    strFind = "[Flagstatus]=" & olNoFlag

To use AdvancedFind in a script, you'd need a loop with a timer to add a
delay to allow the search to complete. I'd stick to Find and Restrict.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> Looking thru the help file and MSDN, I wasn't able to find an example to
> find messages by flagstatus.
> The only examples I found are looping thru the entire folder.
>
> I need to find only certain mailitems who are not flagged, or the Flagicon
> is Red.
>
> For example, i need
> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>
> I know it is possible to search certain mailitems by using "Advanced
> find",
> but how do you do this by script?
>
> Thanks in advance,
>
> PascalB
>
>
Author
29 Oct 2007 3:18 PM
Sue Mosher [MVP-Outlook]
> Could this be done be a simple search and find; perhaps some kind of filter
> or query!?

Yes, that's what the Items.Find and .Restrict methods are for.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> Thanks for the reply, but I'll probably stick with the "for each" script I
> already have to go thru all my items.
>
> I know that the given example wasn't real VBA script, it was only mentioned
> to clear out the problem.
>
> Could this be done be a simple search and find; perhaps some kind of filter
> or query!?

>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
> I always think it's a good idea to create the query string with a separate
> statement, so you can test the result:
>
>    strFind = "[Flagstatus]=""&olNoFlag&"
>    MsgBox strFind
>
> In this case, that would give you a query string of
>
>    [Flagstatus]="&olNoFlag&
>
> which isn't going to find anything at all. First of all, FlagStatus is an
> enumerated property, not a string. Second, the & characters are used in your
> expression as string literals not concatenation operator. So, you're close,
> but not quite there. This would be the query expression that includes the
> actual value of olNoFlag:
>
>    strFind = "[Flagstatus]=" & olNoFlag
>
> To use AdvancedFind in a script, you'd need a loop with a timer to add a
> delay to allow the search to complete. I'd stick to Find and Restrict.
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> Looking thru the help file and MSDN, I wasn't able to find an example to
>> find messages by flagstatus.
>> The only examples I found are looping thru the entire folder.
>>
>> I need to find only certain mailitems who are not flagged, or the Flagicon
>> is Red.
>>
>> For example, i need
>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>
>> I know it is possible to search certain mailitems by using "Advanced
>> find",
>> but how do you do this by script?
>>
>> Thanks in advance,
>>
>> PascalB
>>
>>
>
>
Author
29 Oct 2007 3:49 PM
PascalB
Hi,

Could you give me a example to do so?
I'm stuck and don't have a clue where to start....

Which property "[xxx]" should I give in the Find function?
Where can I find every possible property that I can use in the Find
function?

I wouldn't ask you this if the folder where I should find these mailitems
wasn't so big.
The current script loops thru every +1000 mailitems to find the 20 items
that aren't flagged. (time and processor consuming function)
So that's why I want to narrow down the result by using "Find" and
"FindNext"


TIA.
PascalB




"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
> Could this be done be a simple search and find; perhaps some kind of
> filter
> or query!?

Yes, that's what the Items.Find and .Restrict methods are for.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> Thanks for the reply, but I'll probably stick with the "for each" script I
> already have to go thru all my items.
>
> I know that the given example wasn't real VBA script, it was only
> mentioned
> to clear out the problem.
>
> Could this be done be a simple search and find; perhaps some kind of
> filter
> or query!?

>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
> I always think it's a good idea to create the query string with a separate
> statement, so you can test the result:
>
>    strFind = "[Flagstatus]=""&olNoFlag&"
>    MsgBox strFind
>
> In this case, that would give you a query string of
>
>    [Flagstatus]="&olNoFlag&
>
> which isn't going to find anything at all. First of all, FlagStatus is an
> enumerated property, not a string. Second, the & characters are used in
> your
> expression as string literals not concatenation operator. So, you're
> close,
> but not quite there. This would be the query expression that includes the
> actual value of olNoFlag:
>
>    strFind = "[Flagstatus]=" & olNoFlag
>
> To use AdvancedFind in a script, you'd need a loop with a timer to add a
> delay to allow the search to complete. I'd stick to Find and Restrict.
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> Looking thru the help file and MSDN, I wasn't able to find an example to
>> find messages by flagstatus.
>> The only examples I found are looping thru the entire folder.
>>
>> I need to find only certain mailitems who are not flagged, or the
>> Flagicon
>> is Red.
>>
>> For example, i need
>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>
>> I know it is possible to search certain mailitems by using "Advanced
>> find",
>> but how do you do this by script?
>>
>> Thanks in advance,
>>
>> PascalB
>>
>>
>
>
Author
29 Oct 2007 4:40 PM
Sue Mosher [MVP-Outlook]
When in doubt about the exact names of properties, check the object browser: Press ALt+F11 to open the VBA environment in Outlook, then press F2. Switch from <All Libraries> to Outlook to browse all Outlook objects and their properties, methods, and events.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> Could you give me a example to do so?
> I'm stuck and don't have a clue where to start....
>
> Which property "[xxx]" should I give in the Find function?
> Where can I find every possible property that I can use in the Find
> function?
>
> I wouldn't ask you this if the folder where I should find these mailitems
> wasn't so big.
> The current script loops thru every +1000 mailitems to find the 20 items
> that aren't flagged. (time and processor consuming function)
> So that's why I want to narrow down the result by using "Find" and
> "FindNext"
>
>
> TIA.
> PascalB
>
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>> Could this be done be a simple search and find; perhaps some kind of
>> filter
>> or query!?
>
> Yes, that's what the Items.Find and .Restrict methods are for.
>
> --
> Sue Mosher, Outlook MVP
>   Author of Microsoft Outlook 2007 Programming:
>     Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> Thanks for the reply, but I'll probably stick with the "for each" script I
>> already have to go thru all my items.
>>
>> I know that the given example wasn't real VBA script, it was only
>> mentioned
>> to clear out the problem.
>>
>> Could this be done be a simple search and find; perhaps some kind of
>> filter
>> or query!?
>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>> I always think it's a good idea to create the query string with a separate
>> statement, so you can test the result:
>>
>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>    MsgBox strFind
>>
>> In this case, that would give you a query string of
>>
>>    [Flagstatus]="&olNoFlag&
>>
>> which isn't going to find anything at all. First of all, FlagStatus is an
>> enumerated property, not a string. Second, the & characters are used in
>> your
>> expression as string literals not concatenation operator. So, you're
>> close,
>> but not quite there. This would be the query expression that includes the
>> actual value of olNoFlag:
>>
>>    strFind = "[Flagstatus]=" & olNoFlag
>>
>> To use AdvancedFind in a script, you'd need a loop with a timer to add a
>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> Looking thru the help file and MSDN, I wasn't able to find an example to
>>> find messages by flagstatus.
>>> The only examples I found are looping thru the entire folder.
>>>
>>> I need to find only certain mailitems who are not flagged, or the
>>> Flagicon
>>> is Red.
>>>
>>> For example, i need
>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>
>>> I know it is possible to search certain mailitems by using "Advanced
>>> find",
>>> but how do you do this by script?
>>>
>>> Thanks in advance,
>>>
>>> PascalB
>>>
>>>
>>
>>
>
>
Author
30 Oct 2007 7:56 AM
PascalB
Hi,

I know where to find every property, event and function by pressing
<ALt-F11> + <F2> to open the object browser, but i don't know how to
translate these properties into a find function....

I also know you want to help me by letting me figured everting out by my
own.... I respect that.
I'm not some student who's looking for an easy way out.

I'm totally stuck on this problem, and that's is why I'm consulting this
newsgroup.

Let me explain the entire project;
Some college's in the administration department needed some custom-functions
to examen a certain email folder.

Short;

Function 1:
The mails that are in this folder and are not marked; from these emails I
had to take the subject and insert these into an excel-sheet.
Once this is done, the mails are flagged whit an red flagicon.

Function 2:
The mails who are now flagged with a red flagicon, must be forwarded to a
certain person, which is mentioned in the subject of the email.
Once these mails have been send, the original mail-messages is checked again
as completed.


The only problem is that I must loop thru every mail messages to see which
messages are marked.
Otherwise these function work properly, without any problem... execpt the
time and processor consuming thingy.


PascalB



"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
When in doubt about the exact names of properties, check the object browser:
Press ALt+F11 to open the VBA environment in Outlook, then press F2. Switch
from <All Libraries> to Outlook to browse all Outlook objects and their
properties, methods, and events.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> Could you give me a example to do so?
> I'm stuck and don't have a clue where to start....
>
> Which property "[xxx]" should I give in the Find function?
> Where can I find every possible property that I can use in the Find
> function?
>
> I wouldn't ask you this if the folder where I should find these mailitems
> wasn't so big.
> The current script loops thru every +1000 mailitems to find the 20 items
> that aren't flagged. (time and processor consuming function)
> So that's why I want to narrow down the result by using "Find" and
> "FindNext"
>
>
> TIA.
> PascalB
>
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>> Could this be done be a simple search and find; perhaps some kind of
>> filter
>> or query!?
>
> Yes, that's what the Items.Find and .Restrict methods are for.
>
> --
> Sue Mosher, Outlook MVP
>   Author of Microsoft Outlook 2007 Programming:
>     Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> Thanks for the reply, but I'll probably stick with the "for each" script
>> I
>> already have to go thru all my items.
>>
>> I know that the given example wasn't real VBA script, it was only
>> mentioned
>> to clear out the problem.
>>
>> Could this be done be a simple search and find; perhaps some kind of
>> filter
>> or query!?
>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>> I always think it's a good idea to create the query string with a
>> separate
>> statement, so you can test the result:
>>
>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>    MsgBox strFind
>>
>> In this case, that would give you a query string of
>>
>>    [Flagstatus]="&olNoFlag&
>>
>> which isn't going to find anything at all. First of all, FlagStatus is an
>> enumerated property, not a string. Second, the & characters are used in
>> your
>> expression as string literals not concatenation operator. So, you're
>> close,
>> but not quite there. This would be the query expression that includes the
>> actual value of olNoFlag:
>>
>>    strFind = "[Flagstatus]=" & olNoFlag
>>
>> To use AdvancedFind in a script, you'd need a loop with a timer to add a
>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> Looking thru the help file and MSDN, I wasn't able to find an example to
>>> find messages by flagstatus.
>>> The only examples I found are looping thru the entire folder.
>>>
>>> I need to find only certain mailitems who are not flagged, or the
>>> Flagicon
>>> is Red.
>>>
>>> For example, i need
>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>
>>> I know it is possible to search certain mailitems by using "Advanced
>>> find",
>>> but how do you do this by script?
>>>
>>> Thanks in advance,
>>>
>>> PascalB
>>>
>>>
>>
>>
>
>
Author
30 Oct 2007 12:44 PM
Sue Mosher [MVP-Outlook]
I don't understand where you're stuck, since your original code gave the close to the right syntax for using Items.Find to find items with a FlagStatus property equal to the Outlook constant olNoFlag. You need to make just two changes in that, one of which we've already discussed -- how to use the FlagStatus property in a query string. The other change is that you need an explict Items collection, this:

    Set myItems = myFolder.Items
    strFind = "[FlagStatus]=" & olNoFlag
    Set myItem = myItems.Find(strFlag)

Repeat with FindNext as many times as you need. Or use Restrict instead of Find to return an Items collection that you can iterate with a For Each ... Next loop. Doing a search on FlagIcon would be almost identical, except that the value would be the one appropriate for red flags.

If you still feel stuck, tell us specifically what is stumping you. 

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message news:O6TUppsGIHA.4228@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> I know where to find every property, event and function by pressing
> <ALt-F11> + <F2> to open the object browser, but i don't know how to
> translate these properties into a find function....
>
> I also know you want to help me by letting me figured everting out by my
> own.... I respect that.
> I'm not some student who's looking for an easy way out.
>
> I'm totally stuck on this problem, and that's is why I'm consulting this
> newsgroup.
>
> Let me explain the entire project;
> Some college's in the administration department needed some custom-functions
> to examen a certain email folder.
>
> Short;
>
> Function 1:
> The mails that are in this folder and are not marked; from these emails I
> had to take the subject and insert these into an excel-sheet.
> Once this is done, the mails are flagged whit an red flagicon.
>
> Function 2:
> The mails who are now flagged with a red flagicon, must be forwarded to a
> certain person, which is mentioned in the subject of the email.
> Once these mails have been send, the original mail-messages is checked again
> as completed.
>
>
> The only problem is that I must loop thru every mail messages to see which
> messages are marked.
> Otherwise these function work properly, without any problem... execpt the
> time and processor consuming thingy.
>
>
> PascalB
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
> When in doubt about the exact names of properties, check the object browser:
> Press ALt+F11 to open the VBA environment in Outlook, then press F2. Switch
> from <All Libraries> to Outlook to browse all Outlook objects and their
> properties, methods, and events.
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
>> Hi,
>>
>> Could you give me a example to do so?
>> I'm stuck and don't have a clue where to start....
>>
>> Which property "[xxx]" should I give in the Find function?
>> Where can I find every possible property that I can use in the Find
>> function?
>>
>> I wouldn't ask you this if the folder where I should find these mailitems
>> wasn't so big.
>> The current script loops thru every +1000 mailitems to find the 20 items
>> that aren't flagged. (time and processor consuming function)
>> So that's why I want to narrow down the result by using "Find" and
>> "FindNext"
>>
>>
>> TIA.
>> PascalB
>>
>>
>>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>>> Could this be done be a simple search and find; perhaps some kind of
>>> filter
>>> or query!?
>>
>> Yes, that's what the Items.Find and .Restrict methods are for.
>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>>> Hi,
>>>
>>> Thanks for the reply, but I'll probably stick with the "for each" script
>>> I
>>> already have to go thru all my items.
>>>
>>> I know that the given example wasn't real VBA script, it was only
>>> mentioned
>>> to clear out the problem.
>>>
>>> Could this be done be a simple search and find; perhaps some kind of
>>> filter
>>> or query!?
>>
>>>
>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>>> I always think it's a good idea to create the query string with a
>>> separate
>>> statement, so you can test the result:
>>>
>>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>>    MsgBox strFind
>>>
>>> In this case, that would give you a query string of
>>>
>>>    [Flagstatus]="&olNoFlag&
>>>
>>> which isn't going to find anything at all. First of all, FlagStatus is an
>>> enumerated property, not a string. Second, the & characters are used in
>>> your
>>> expression as string literals not concatenation operator. So, you're
>>> close,
>>> but not quite there. This would be the query expression that includes the
>>> actual value of olNoFlag:
>>>
>>>    strFind = "[Flagstatus]=" & olNoFlag
>>>
>>> To use AdvancedFind in a script, you'd need a loop with a timer to add a
>>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>>
>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>> Hi,
>>>>
>>>> Looking thru the help file and MSDN, I wasn't able to find an example to
>>>> find messages by flagstatus.
>>>> The only examples I found are looping thru the entire folder.
>>>>
>>>> I need to find only certain mailitems who are not flagged, or the
>>>> Flagicon
>>>> is Red.
>>>>
>>>> For example, i need
>>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>>
>>>> I know it is possible to search certain mailitems by using "Advanced
>>>> find",
>>>> but how do you do this by script?
>>>>
>>>> Thanks in advance,
>>>>
>>>> PascalB
Author
30 Oct 2007 1:30 PM
PascalB
Hi Sue,

Thanks for the response.
Using the given example, I don't see a result.

I do a local test on a subfolder 'Test' of my Inbox, this folder contains 5
mailitems, 4 are flagged 1 is not

'---- Snipped ----'

Set myfolder = myNameSpace.Folders("Inbox").Folders("Test")
Set myItems = myFolder.Items

Msgbox myItems.count  ' returns 5 (mail items)

' first attempt to find an mailitem
strFind = "[FlagStatus]=" & olNoFlag
Set myItem = myItems.Find(strFind)    '-> myItem = Nothing !!!
MsgBox myItem.Subject


' second attempt to find an mailitem
strFind = "[FlagIcon]=" & olNoFlagIcon
Set myItem = myItems.Find(strFind)   '-> myItem = Nothing !!!
MsgBox myItem.Subject

'---- end snipped ----'

What am I missing here!?

Cheers,
PascalB








"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:uec0bMvGIHA.3980@TK2MSFTNGP03.phx.gbl...
I don't understand where you're stuck, since your original code gave the
close to the right syntax for using Items.Find to find items with a
FlagStatus property equal to the Outlook constant olNoFlag. You need to make
just two changes in that, one of which we've already discussed -- how to use
the FlagStatus property in a query string. The other change is that you need
an explict Items collection, this:

    Set myItems = myFolder.Items
    strFind = "[FlagStatus]=" & olNoFlag
    Set myItem = myItems.Find(strFlag)

Repeat with FindNext as many times as you need. Or use Restrict instead of
Find to return an Items collection that you can iterate with a For Each ...
Next loop. Doing a search on FlagIcon would be almost identical, except that
the value would be the one appropriate for red flags.

If you still feel stuck, tell us specifically what is stumping you.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
news:O6TUppsGIHA.4228@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> I know where to find every property, event and function by pressing
> <ALt-F11> + <F2> to open the object browser, but i don't know how to
> translate these properties into a find function....
>
> I also know you want to help me by letting me figured everting out by my
> own.... I respect that.
> I'm not some student who's looking for an easy way out.
>
> I'm totally stuck on this problem, and that's is why I'm consulting this
> newsgroup.
>
> Let me explain the entire project;
> Some college's in the administration department needed some
> custom-functions
> to examen a certain email folder.
>
> Short;
>
> Function 1:
> The mails that are in this folder and are not marked; from these emails I
> had to take the subject and insert these into an excel-sheet.
> Once this is done, the mails are flagged whit an red flagicon.
>
> Function 2:
> The mails who are now flagged with a red flagicon, must be forwarded to a
> certain person, which is mentioned in the subject of the email.
> Once these mails have been send, the original mail-messages is checked
> again
> as completed.
>
>
> The only problem is that I must loop thru every mail messages to see which
> messages are marked.
> Otherwise these function work properly, without any problem... execpt the
> time and processor consuming thingy.
>
>
> PascalB
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
> When in doubt about the exact names of properties, check the object
> browser:
> Press ALt+F11 to open the VBA environment in Outlook, then press F2.
> Switch
> from <All Libraries> to Outlook to browse all Outlook objects and their
> properties, methods, and events.
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
>> Hi,
>>
>> Could you give me a example to do so?
>> I'm stuck and don't have a clue where to start....
>>
>> Which property "[xxx]" should I give in the Find function?
>> Where can I find every possible property that I can use in the Find
>> function?
>>
>> I wouldn't ask you this if the folder where I should find these mailitems
>> wasn't so big.
>> The current script loops thru every +1000 mailitems to find the 20 items
>> that aren't flagged. (time and processor consuming function)
>> So that's why I want to narrow down the result by using "Find" and
>> "FindNext"
>>
>>
>> TIA.
>> PascalB
>>
>>
>>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>>> Could this be done be a simple search and find; perhaps some kind of
>>> filter
>>> or query!?
>>
>> Yes, that's what the Items.Find and .Restrict methods are for.
>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>>> Hi,
>>>
>>> Thanks for the reply, but I'll probably stick with the "for each" script
>>> I
>>> already have to go thru all my items.
>>>
>>> I know that the given example wasn't real VBA script, it was only
>>> mentioned
>>> to clear out the problem.
>>>
>>> Could this be done be a simple search and find; perhaps some kind of
>>> filter
>>> or query!?
>>
>>>
>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>>> I always think it's a good idea to create the query string with a
>>> separate
>>> statement, so you can test the result:
>>>
>>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>>    MsgBox strFind
>>>
>>> In this case, that would give you a query string of
>>>
>>>    [Flagstatus]="&olNoFlag&
>>>
>>> which isn't going to find anything at all. First of all, FlagStatus is
>>> an
>>> enumerated property, not a string. Second, the & characters are used in
>>> your
>>> expression as string literals not concatenation operator. So, you're
>>> close,
>>> but not quite there. This would be the query expression that includes
>>> the
>>> actual value of olNoFlag:
>>>
>>>    strFind = "[Flagstatus]=" & olNoFlag
>>>
>>> To use AdvancedFind in a script, you'd need a loop with a timer to add a
>>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>>
>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>> Hi,
>>>>
>>>> Looking thru the help file and MSDN, I wasn't able to find an example
>>>> to
>>>> find messages by flagstatus.
>>>> The only examples I found are looping thru the entire folder.
>>>>
>>>> I need to find only certain mailitems who are not flagged, or the
>>>> Flagicon
>>>> is Red.
>>>>
>>>> For example, i need
>>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>>
>>>> I know it is possible to search certain mailitems by using "Advanced
>>>> find",
>>>> but how do you do this by script?
>>>>
>>>> Thanks in advance,
>>>>
>>>> PascalB
Author
30 Oct 2007 2:38 PM
Sue Mosher [MVP-Outlook]
My guess is that you're returning the wrong folder. If myNamespace is a Namespace object, then myNamespace.Folders("Inbox") is not likely to be the correct way to retrieve your Inbox folder. That expression would only work if you had a .pst file with the display name Inbox.

To return your default Inbox folder, use the Namespace.GetDefaultFolder method. Once you have the Inbox, you can get the Test folder form its Folders colleciton.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message news:%23jA7ZkvGIHA.1316@TK2MSFTNGP02.phx.gbl...
> Hi Sue,
>
> Thanks for the response.
> Using the given example, I don't see a result.
>
> I do a local test on a subfolder 'Test' of my Inbox, this folder contains 5
> mailitems, 4 are flagged 1 is not
>
> '---- Snipped ----'
>
> Set myfolder = myNameSpace.Folders("Inbox").Folders("Test")
> Set myItems = myFolder.Items
>
> Msgbox myItems.count  ' returns 5 (mail items)
>
> ' first attempt to find an mailitem
> strFind = "[FlagStatus]=" & olNoFlag
> Set myItem = myItems.Find(strFind)    '-> myItem = Nothing !!!
> MsgBox myItem.Subject
>
>
> ' second attempt to find an mailitem
> strFind = "[FlagIcon]=" & olNoFlagIcon
> Set myItem = myItems.Find(strFind)   '-> myItem = Nothing !!!
> MsgBox myItem.Subject
>
> '---- end snipped ----'
>
> What am I missing here!?
>
> Cheers,
> PascalB
>
>
>
>
>
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:uec0bMvGIHA.3980@TK2MSFTNGP03.phx.gbl...
> I don't understand where you're stuck, since your original code gave the
> close to the right syntax for using Items.Find to find items with a
> FlagStatus property equal to the Outlook constant olNoFlag. You need to make
> just two changes in that, one of which we've already discussed -- how to use
> the FlagStatus property in a query string. The other change is that you need
> an explict Items collection, this:
>
>    Set myItems = myFolder.Items
>    strFind = "[FlagStatus]=" & olNoFlag
>    Set myItem = myItems.Find(strFlag)
>
> Repeat with FindNext as many times as you need. Or use Restrict instead of
> Find to return an Items collection that you can iterate with a For Each ...
> Next loop. Doing a search on FlagIcon would be almost identical, except that
> the value would be the one appropriate for red flags.
>
> If you still feel stuck, tell us specifically what is stumping you.
>
> --
> Sue Mosher, Outlook MVP
>   Author of Microsoft Outlook 2007 Programming:
>     Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:O6TUppsGIHA.4228@TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> I know where to find every property, event and function by pressing
>> <ALt-F11> + <F2> to open the object browser, but i don't know how to
>> translate these properties into a find function....
>>
>> I also know you want to help me by letting me figured everting out by my
>> own.... I respect that.
>> I'm not some student who's looking for an easy way out.
>>
>> I'm totally stuck on this problem, and that's is why I'm consulting this
>> newsgroup.
>>
>> Let me explain the entire project;
>> Some college's in the administration department needed some
>> custom-functions
>> to examen a certain email folder.
>>
>> Short;
>>
>> Function 1:
>> The mails that are in this folder and are not marked; from these emails I
>> had to take the subject and insert these into an excel-sheet.
>> Once this is done, the mails are flagged whit an red flagicon.
>>
>> Function 2:
>> The mails who are now flagged with a red flagicon, must be forwarded to a
>> certain person, which is mentioned in the subject of the email.
>> Once these mails have been send, the original mail-messages is checked
>> again
>> as completed.
>>
>>
>> The only problem is that I must loop thru every mail messages to see which
>> messages are marked.
>> Otherwise these function work properly, without any problem... execpt the
>> time and processor consuming thingy.
>>
>>
>> PascalB
>>
>>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
>> When in doubt about the exact names of properties, check the object
>> browser:
>> Press ALt+F11 to open the VBA environment in Outlook, then press F2.
>> Switch
>> from <All Libraries> to Outlook to browse all Outlook objects and their
>> properties, methods, and events.
>>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
>>> Hi,
>>>
>>> Could you give me a example to do so?
>>> I'm stuck and don't have a clue where to start....
>>>
>>> Which property "[xxx]" should I give in the Find function?
>>> Where can I find every possible property that I can use in the Find
>>> function?
>>>
>>> I wouldn't ask you this if the folder where I should find these mailitems
>>> wasn't so big.
>>> The current script loops thru every +1000 mailitems to find the 20 items
>>> that aren't flagged. (time and processor consuming function)
>>> So that's why I want to narrow down the result by using "Find" and
>>> "FindNext"
>>>
>>>
>>> TIA.
>>> PascalB
>>>
>>>
>>>
>>>
>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>>>> Could this be done be a simple search and find; perhaps some kind of
>>>> filter
>>>> or query!?
>>>
>>> Yes, that's what the Items.Find and .Restrict methods are for.
>>
>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>>>> Hi,
>>>>
>>>> Thanks for the reply, but I'll probably stick with the "for each" script
>>>> I
>>>> already have to go thru all my items.
>>>>
>>>> I know that the given example wasn't real VBA script, it was only
>>>> mentioned
>>>> to clear out the problem.
>>>>
>>>> Could this be done be a simple search and find; perhaps some kind of
>>>> filter
>>>> or query!?
>>>
>>>>
>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>>>> I always think it's a good idea to create the query string with a
>>>> separate
>>>> statement, so you can test the result:
>>>>
>>>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>>>    MsgBox strFind
>>>>
>>>> In this case, that would give you a query string of
>>>>
>>>>    [Flagstatus]="&olNoFlag&
>>>>
>>>> which isn't going to find anything at all. First of all, FlagStatus is
>>>> an
>>>> enumerated property, not a string. Second, the & characters are used in
>>>> your
>>>> expression as string literals not concatenation operator. So, you're
>>>> close,
>>>> but not quite there. This would be the query expression that includes
>>>> the
>>>> actual value of olNoFlag:
>>>>
>>>>    strFind = "[Flagstatus]=" & olNoFlag
>>>>
>>>> To use AdvancedFind in a script, you'd need a loop with a timer to add a
>>>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>>>
>>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>>> Hi,
>>>>>
>>>>> Looking thru the help file and MSDN, I wasn't able to find an example
>>>>> to
>>>>> find messages by flagstatus.
>>>>> The only examples I found are looping thru the entire folder.
>>>>>
>>>>> I need to find only certain mailitems who are not flagged, or the
>>>>> Flagicon
>>>>> is Red.
>>>>>
>>>>> For example, i need
>>>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>>>
>>>>> I know it is possible to search certain mailitems by using "Advanced
>>>>> find",
>>>>> but how do you do this by script?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> PascalB
>
>
Author
31 Oct 2007 12:49 PM
PascalB
Hi Sue,

No succes yet:

'---- Snipped ----'
    Set myolApp = Application
    Set myNameSpace = myolApp.GetNamespace("MAPI")
    Set myfolder =
myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Test")

    Set myItems = myfolder.Items
    MsgBox myItems.Count      ' returns 5 (mail items)


    strFind = "[FlagStatus]=" & olNoFlag
    Set myItem = myItems.Find(strFind) '=> nothing!!!
    MsgBox myItem.Subject

    strFind = "[FlagIcon]=" & olRedFlagIcon
    Set myItem = myItems.Find(strFind) '=> nothing!!!
    MsgBox myItem.Subject

    strFind = "[SenderName]='KF in'"
    Set myItem = myItems.Find(strFind)
    MsgBox myItem.Subject  '=> returns the mail subject

'---- end snipped ----'


The intresting thing is that myFolder is the right folder, because it
returns the exact quantity of mailitems.
I also use myFolder to loop thru for further processing and the property
[SenderName] gives a result.

Maybe the property [Flagstatus] and [FlagIcon] do not apply as an property
in the Find function.

(Environment: Win XP sp2 - Outlook 2003)

Any suggestions?

Cheers,
Pascal B






"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:uUxSdKwGIHA.4296@TK2MSFTNGP04.phx.gbl...
My guess is that you're returning the wrong folder. If myNamespace is a
Namespace object, then myNamespace.Folders("Inbox") is not likely to be the
correct way to retrieve your Inbox folder. That expression would only work
if you had a .pst file with the display name Inbox.

To return your default Inbox folder, use the Namespace.GetDefaultFolder
method. Once you have the Inbox, you can get the Test folder form its
Folders colleciton.

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
news:%23jA7ZkvGIHA.1316@TK2MSFTNGP02.phx.gbl...
> Hi Sue,
>
> Thanks for the response.
> Using the given example, I don't see a result.
>
> I do a local test on a subfolder 'Test' of my Inbox, this folder contains
> 5
> mailitems, 4 are flagged 1 is not
>
> '---- Snipped ----'
>
> Set myfolder = myNameSpace.Folders("Inbox").Folders("Test")
> Set myItems = myFolder.Items
>
> Msgbox myItems.count  ' returns 5 (mail items)
>
> ' first attempt to find an mailitem
> strFind = "[FlagStatus]=" & olNoFlag
> Set myItem = myItems.Find(strFind)    '-> myItem = Nothing !!!
> MsgBox myItem.Subject
>
>
> ' second attempt to find an mailitem
> strFind = "[FlagIcon]=" & olNoFlagIcon
> Set myItem = myItems.Find(strFind)   '-> myItem = Nothing !!!
> MsgBox myItem.Subject
>
> '---- end snipped ----'
>
> What am I missing here!?
>
> Cheers,
> PascalB
>
>
>
>
>
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:uec0bMvGIHA.3980@TK2MSFTNGP03.phx.gbl...
> I don't understand where you're stuck, since your original code gave the
> close to the right syntax for using Items.Find to find items with a
> FlagStatus property equal to the Outlook constant olNoFlag. You need to
> make
> just two changes in that, one of which we've already discussed -- how to
> use
> the FlagStatus property in a query string. The other change is that you
> need
> an explict Items collection, this:
>
>    Set myItems = myFolder.Items
>    strFind = "[FlagStatus]=" & olNoFlag
>    Set myItem = myItems.Find(strFlag)
>
> Repeat with FindNext as many times as you need. Or use Restrict instead of
> Find to return an Items collection that you can iterate with a For Each
> ...
> Next loop. Doing a search on FlagIcon would be almost identical, except
> that
> the value would be the one appropriate for red flags.
>
> If you still feel stuck, tell us specifically what is stumping you.
>
> --
> Sue Mosher, Outlook MVP
>   Author of Microsoft Outlook 2007 Programming:
>     Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:O6TUppsGIHA.4228@TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> I know where to find every property, event and function by pressing
>> <ALt-F11> + <F2> to open the object browser, but i don't know how to
>> translate these properties into a find function....
>>
>> I also know you want to help me by letting me figured everting out by my
>> own.... I respect that.
>> I'm not some student who's looking for an easy way out.
>>
>> I'm totally stuck on this problem, and that's is why I'm consulting this
>> newsgroup.
>>
>> Let me explain the entire project;
>> Some college's in the administration department needed some
>> custom-functions
>> to examen a certain email folder.
>>
>> Short;
>>
>> Function 1:
>> The mails that are in this folder and are not marked; from these emails I
>> had to take the subject and insert these into an excel-sheet.
>> Once this is done, the mails are flagged whit an red flagicon.
>>
>> Function 2:
>> The mails who are now flagged with a red flagicon, must be forwarded to a
>> certain person, which is mentioned in the subject of the email.
>> Once these mails have been send, the original mail-messages is checked
>> again
>> as completed.
>>
>>
>> The only problem is that I must loop thru every mail messages to see
>> which
>> messages are marked.
>> Otherwise these function work properly, without any problem... execpt the
>> time and processor consuming thingy.
>>
>>
>> PascalB
>>
>>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
>> When in doubt about the exact names of properties, check the object
>> browser:
>> Press ALt+F11 to open the VBA environment in Outlook, then press F2.
>> Switch
>> from <All Libraries> to Outlook to browse all Outlook objects and their
>> properties, methods, and events.
>>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
>>> Hi,
>>>
>>> Could you give me a example to do so?
>>> I'm stuck and don't have a clue where to start....
>>>
>>> Which property "[xxx]" should I give in the Find function?
>>> Where can I find every possible property that I can use in the Find
>>> function?
>>>
>>> I wouldn't ask you this if the folder where I should find these
>>> mailitems
>>> wasn't so big.
>>> The current script loops thru every +1000 mailitems to find the 20 items
>>> that aren't flagged. (time and processor consuming function)
>>> So that's why I want to narrow down the result by using "Find" and
>>> "FindNext"
>>>
>>>
>>> TIA.
>>> PascalB
>>>
>>>
>>>
>>>
>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>>>> Could this be done be a simple search and find; perhaps some kind of
>>>> filter
>>>> or query!?
>>>
>>> Yes, that's what the Items.Find and .Restrict methods are for.
>>
>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>>>> Hi,
>>>>
>>>> Thanks for the reply, but I'll probably stick with the "for each"
>>>> script
>>>> I
>>>> already have to go thru all my items.
>>>>
>>>> I know that the given example wasn't real VBA script, it was only
>>>> mentioned
>>>> to clear out the problem.
>>>>
>>>> Could this be done be a simple search and find; perhaps some kind of
>>>> filter
>>>> or query!?
>>>
>>>>
>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>>>> I always think it's a good idea to create the query string with a
>>>> separate
>>>> statement, so you can test the result:
>>>>
>>>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>>>    MsgBox strFind
>>>>
>>>> In this case, that would give you a query string of
>>>>
>>>>    [Flagstatus]="&olNoFlag&
>>>>
>>>> which isn't going to find anything at all. First of all, FlagStatus is
>>>> an
>>>> enumerated property, not a string. Second, the & characters are used in
>>>> your
>>>> expression as string literals not concatenation operator. So, you're
>>>> close,
>>>> but not quite there. This would be the query expression that includes
>>>> the
>>>> actual value of olNoFlag:
>>>>
>>>>    strFind = "[Flagstatus]=" & olNoFlag
>>>>
>>>> To use AdvancedFind in a script, you'd need a loop with a timer to add
>>>> a
>>>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>>>
>>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>>> Hi,
>>>>>
>>>>> Looking thru the help file and MSDN, I wasn't able to find an example
>>>>> to
>>>>> find messages by flagstatus.
>>>>> The only examples I found are looping thru the entire folder.
>>>>>
>>>>> I need to find only certain mailitems who are not flagged, or the
>>>>> Flagicon
>>>>> is Red.
>>>>>
>>>>> For example, i need
>>>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>>>
>>>>> I know it is possible to search certain mailitems by using "Advanced
>>>>> find",
>>>>> but how do you do this by script?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> PascalB
>
>
Author
31 Oct 2007 2:15 PM
Sue Mosher [MVP-Outlook]
This turned out to be a quite subtle and unexpected problem with a slightly complex solution -- using DASL syntax to return the desired search results using Restrict instead of Find. This was the code snippet that worked for me:

    On Error Resume Next
    Set myOlApp = Application
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myfolder = _
        myNamespace.GetDefaultFolder(olFolderInbox).Folders("Test")

    Set myItems = myfolder.Items
    Debug.Print myItems.count      ' returns 5 (mail items)

    ' search for items with no flags
    strSearch = Chr(34) & _
      "http://schemas.microsoft.com/mapi/proptag/0x0C17000B" & _
      Chr(34) & "= False"
    Debug.Print strSearch
    Set myitemsnoflag = myItems.Restrict("@SQL=" & strSearch)
    Debug.Print myitemsnoflag.count
    For Each myItem In myitemsnoflag
        Debug.Print myItem.Subject
    Next

    ' search for items with red flags
    strSearch = Chr(34) & _
      "http://schemas.microsoft.com/mapi/proptag/0x10950003" & _
       Chr(34) & "= " & CStr(olRedFlagIcon)
    Debug.Print strSearch
    Set myitemsredflag = myItems.Restrict("@SQL=" & strSearch)
    Debug.Print myitemsredflag.count
    For Each myItem In myitemsredflag
        Debug.Print myItem.Subject
    Next

For more information on using the DASL search syntax in Outlook, see http://www.outlookcode.com/news.aspx?id=30

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message news:uOcQtx7GIHA.3600@TK2MSFTNGP06.phx.gbl...
> Hi Sue,
>
> No succes yet:
>
> '---- Snipped ----'
>    Set myolApp = Application
>    Set myNameSpace = myolApp.GetNamespace("MAPI")
>    Set myfolder =
> myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Test")
>
>    Set myItems = myfolder.Items
>    MsgBox myItems.Count      ' returns 5 (mail items)
>
>
>    strFind = "[FlagStatus]=" & olNoFlag
>    Set myItem = myItems.Find(strFind) '=> nothing!!!
>    MsgBox myItem.Subject
>
>    strFind = "[FlagIcon]=" & olRedFlagIcon
>    Set myItem = myItems.Find(strFind) '=> nothing!!!
>    MsgBox myItem.Subject
>
>    strFind = "[SenderName]='KF in'"
>    Set myItem = myItems.Find(strFind)
>    MsgBox myItem.Subject  '=> returns the mail subject
>
> '---- end snipped ----'
>
>
> The intresting thing is that myFolder is the right folder, because it
> returns the exact quantity of mailitems.
> I also use myFolder to loop thru for further processing and the property
> [SenderName] gives a result.
>
> Maybe the property [Flagstatus] and [FlagIcon] do not apply as an property
> in the Find function.
>
> (Environment: Win XP sp2 - Outlook 2003)
>
> Any suggestions?
>
> Cheers,
> Pascal B
>
>
>
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:uUxSdKwGIHA.4296@TK2MSFTNGP04.phx.gbl...
> My guess is that you're returning the wrong folder. If myNamespace is a
> Namespace object, then myNamespace.Folders("Inbox") is not likely to be the
> correct way to retrieve your Inbox folder. That expression would only work
> if you had a .pst file with the display name Inbox.
>
> To return your default Inbox folder, use the Namespace.GetDefaultFolder
> method. Once you have the Inbox, you can get the Test folder form its
> Folders colleciton.
>
> --
> Sue Mosher, Outlook MVP
>   Author of Microsoft Outlook 2007 Programming:
>     Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:%23jA7ZkvGIHA.1316@TK2MSFTNGP02.phx.gbl...
>> Hi Sue,
>>
>> Thanks for the response.
>> Using the given example, I don't see a result.
>>
>> I do a local test on a subfolder 'Test' of my Inbox, this folder contains
>> 5
>> mailitems, 4 are flagged 1 is not
>>
>> '---- Snipped ----'
>>
>> Set myfolder = myNameSpace.Folders("Inbox").Folders("Test")
>> Set myItems = myFolder.Items
>>
>> Msgbox myItems.count  ' returns 5 (mail items)
>>
>> ' first attempt to find an mailitem
>> strFind = "[FlagStatus]=" & olNoFlag
>> Set myItem = myItems.Find(strFind)    '-> myItem = Nothing !!!
>> MsgBox myItem.Subject
>>
>>
>> ' second attempt to find an mailitem
>> strFind = "[FlagIcon]=" & olNoFlagIcon
>> Set myItem = myItems.Find(strFind)   '-> myItem = Nothing !!!
>> MsgBox myItem.Subject
>>
>> '---- end snipped ----'
>>
>> What am I missing here!?
>>
>> Cheers,
>> PascalB
>>
>>
>>
>>
>>
>>
>>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:uec0bMvGIHA.3980@TK2MSFTNGP03.phx.gbl...
>> I don't understand where you're stuck, since your original code gave the
>> close to the right syntax for using Items.Find to find items with a
>> FlagStatus property equal to the Outlook constant olNoFlag. You need to
>> make
>> just two changes in that, one of which we've already discussed -- how to
>> use
>> the FlagStatus property in a query string. The other change is that you
>> need
>> an explict Items collection, this:
>>
>>    Set myItems = myFolder.Items
>>    strFind = "[FlagStatus]=" & olNoFlag
>>    Set myItem = myItems.Find(strFlag)
>>
>> Repeat with FindNext as many times as you need. Or use Restrict instead of
>> Find to return an Items collection that you can iterate with a For Each
>> ...
>> Next loop. Doing a search on FlagIcon would be almost identical, except
>> that
>> the value would be the one appropriate for red flags.
>>
>> If you still feel stuck, tell us specifically what is stumping you.
>>
>> --
>> Sue Mosher, Outlook MVP
>>   Author of Microsoft Outlook 2007 Programming:
>>     Jumpstart for Power Users and Administrators
>>    http://www.outlookcode.com/article.aspx?id=54
>>
>>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:O6TUppsGIHA.4228@TK2MSFTNGP02.phx.gbl...
>>> Hi,
>>>
>>> I know where to find every property, event and function by pressing
>>> <ALt-F11> + <F2> to open the object browser, but i don't know how to
>>> translate these properties into a find function....
>>>
>>> I also know you want to help me by letting me figured everting out by my
>>> own.... I respect that.
>>> I'm not some student who's looking for an easy way out.
>>>
>>> I'm totally stuck on this problem, and that's is why I'm consulting this
>>> newsgroup.
>>>
>>> Let me explain the entire project;
>>> Some college's in the administration department needed some
>>> custom-functions
>>> to examen a certain email folder.
>>>
>>> Short;
>>>
>>> Function 1:
>>> The mails that are in this folder and are not marked; from these emails I
>>> had to take the subject and insert these into an excel-sheet.
>>> Once this is done, the mails are flagged whit an red flagicon.
>>>
>>> Function 2:
>>> The mails who are now flagged with a red flagicon, must be forwarded to a
>>> certain person, which is mentioned in the subject of the email.
>>> Once these mails have been send, the original mail-messages is checked
>>> again
>>> as completed.
>>>
>>>
>>> The only problem is that I must loop thru every mail messages to see
>>> which
>>> messages are marked.
>>> Otherwise these function work properly, without any problem... execpt the
>>> time and processor consuming thingy.
>>>
>>>
>>> PascalB
>>>
>>>
>>>
>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>> news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
>>> When in doubt about the exact names of properties, check the object
>>> browser:
>>> Press ALt+F11 to open the VBA environment in Outlook, then press F2.
>>> Switch
>>> from <All Libraries> to Outlook to browse all Outlook objects and their
>>> properties, methods, and events.
>>>
>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>> news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
>>>> Hi,
>>>>
>>>> Could you give me a example to do so?
>>>> I'm stuck and don't have a clue where to start....
>>>>
>>>> Which property "[xxx]" should I give in the Find function?
>>>> Where can I find every possible property that I can use in the Find
>>>> function?
>>>>
>>>> I wouldn't ask you this if the folder where I should find these
>>>> mailitems
>>>> wasn't so big.
>>>> The current script loops thru every +1000 mailitems to find the 20 items
>>>> that aren't flagged. (time and processor consuming function)
>>>> So that's why I want to narrow down the result by using "Find" and
>>>> "FindNext"
>>>>
>>>>
>>>> TIA.
>>>> PascalB
>>>>
>>>>
>>>>
>>>>
>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>>> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>>>>> Could this be done be a simple search and find; perhaps some kind of
>>>>> filter
>>>>> or query!?
>>>>
>>>> Yes, that's what the Items.Find and .Restrict methods are for.
>>>
>>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>>> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>>>>> Hi,
>>>>>
>>>>> Thanks for the reply, but I'll probably stick with the "for each"
>>>>> script
>>>>> I
>>>>> already have to go thru all my items.
>>>>>
>>>>> I know that the given example wasn't real VBA script, it was only
>>>>> mentioned
>>>>> to clear out the problem.
>>>>>
>>>>> Could this be done be a simple search and find; perhaps some kind of
>>>>> filter
>>>>> or query!?
>>>>
>>>>>
>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>>>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>>>>> I always think it's a good idea to create the query string with a
>>>>> separate
>>>>> statement, so you can test the result:
>>>>>
>>>>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>>>>    MsgBox strFind
>>>>>
>>>>> In this case, that would give you a query string of
>>>>>
>>>>>    [Flagstatus]="&olNoFlag&
>>>>>
>>>>> which isn't going to find anything at all. First of all, FlagStatus is
>>>>> an
>>>>> enumerated property, not a string. Second, the & characters are used in
>>>>> your
>>>>> expression as string literals not concatenation operator. So, you're
>>>>> close,
>>>>> but not quite there. This would be the query expression that includes
>>>>> the
>>>>> actual value of olNoFlag:
>>>>>
>>>>>    strFind = "[Flagstatus]=" & olNoFlag
>>>>>
>>>>> To use AdvancedFind in a script, you'd need a loop with a timer to add
>>>>> a
>>>>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>>>>
>>>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>>>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>>>> Hi,
>>>>>>
>>>>>> Looking thru the help file and MSDN, I wasn't able to find an example
>>>>>> to
>>>>>> find messages by flagstatus.
>>>>>> The only examples I found are looping thru the entire folder.
>>>>>>
>>>>>> I need to find only certain mailitems who are not flagged, or the
>>>>>> Flagicon
>>>>>> is Red.
>>>>>>
>>>>>> For example, i need
>>>>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>>>>
>>>>>> I know it is possible to search certain mailitems by using "Advanced
>>>>>> find",
>>>>>> but how do you do this by script?
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> PascalB
>>
>>
>
>
Author
31 Oct 2007 2:49 PM
PascalB
Sue,

I'll give it a try.

Thanks for keeping track off the problem and providing an solution.

Best Regards,
PascalB




"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:eG3L3n8GIHA.4112@TK2MSFTNGP05.phx.gbl...
This turned out to be a quite subtle and unexpected problem with a slightly
complex solution -- using DASL syntax to return the desired search results
using Restrict instead of Find. This was the code snippet that worked for
me:

    On Error Resume Next
    Set myOlApp = Application
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myfolder = _
        myNamespace.GetDefaultFolder(olFolderInbox).Folders("Test")

    Set myItems = myfolder.Items
    Debug.Print myItems.count      ' returns 5 (mail items)

    ' search for items with no flags
    strSearch = Chr(34) & _
      "http://schemas.microsoft.com/mapi/proptag/0x0C17000B" & _
      Chr(34) & "= False"
    Debug.Print strSearch
    Set myitemsnoflag = myItems.Restrict("@SQL=" & strSearch)
    Debug.Print myitemsnoflag.count
    For Each myItem In myitemsnoflag
        Debug.Print myItem.Subject
    Next

    ' search for items with red flags
    strSearch = Chr(34) & _
      "http://schemas.microsoft.com/mapi/proptag/0x10950003" & _
       Chr(34) & "= " & CStr(olRedFlagIcon)
    Debug.Print strSearch
    Set myitemsredflag = myItems.Restrict("@SQL=" & strSearch)
    Debug.Print myitemsredflag.count
    For Each myItem In myitemsredflag
        Debug.Print myItem.Subject
    Next

For more information on using the DASL search syntax in Outlook, see
http://www.outlookcode.com/news.aspx?id=30

--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


Show quote
"PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
news:uOcQtx7GIHA.3600@TK2MSFTNGP06.phx.gbl...
> Hi Sue,
>
> No succes yet:
>
> '---- Snipped ----'
>    Set myolApp = Application
>    Set myNameSpace = myolApp.GetNamespace("MAPI")
>    Set myfolder =
> myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Test")
>
>    Set myItems = myfolder.Items
>    MsgBox myItems.Count      ' returns 5 (mail items)
>
>
>    strFind = "[FlagStatus]=" & olNoFlag
>    Set myItem = myItems.Find(strFind) '=> nothing!!!
>    MsgBox myItem.Subject
>
>    strFind = "[FlagIcon]=" & olRedFlagIcon
>    Set myItem = myItems.Find(strFind) '=> nothing!!!
>    MsgBox myItem.Subject
>
>    strFind = "[SenderName]='KF in'"
>    Set myItem = myItems.Find(strFind)
>    MsgBox myItem.Subject  '=> returns the mail subject
>
> '---- end snipped ----'
>
>
> The intresting thing is that myFolder is the right folder, because it
> returns the exact quantity of mailitems.
> I also use myFolder to loop thru for further processing and the property
> [SenderName] gives a result.
>
> Maybe the property [Flagstatus] and [FlagIcon] do not apply as an property
> in the Find function.
>
> (Environment: Win XP sp2 - Outlook 2003)
>
> Any suggestions?
>
> Cheers,
> Pascal B
>
>
>
>
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:uUxSdKwGIHA.4296@TK2MSFTNGP04.phx.gbl...
> My guess is that you're returning the wrong folder. If myNamespace is a
> Namespace object, then myNamespace.Folders("Inbox") is not likely to be
> the
> correct way to retrieve your Inbox folder. That expression would only work
> if you had a .pst file with the display name Inbox.
>
> To return your default Inbox folder, use the Namespace.GetDefaultFolder
> method. Once you have the Inbox, you can get the Test folder form its
> Folders colleciton.
>
> --
> Sue Mosher, Outlook MVP
>   Author of Microsoft Outlook 2007 Programming:
>     Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
>
> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
> news:%23jA7ZkvGIHA.1316@TK2MSFTNGP02.phx.gbl...
>> Hi Sue,
>>
>> Thanks for the response.
>> Using the given example, I don't see a result.
>>
>> I do a local test on a subfolder 'Test' of my Inbox, this folder contains
>> 5
>> mailitems, 4 are flagged 1 is not
>>
>> '---- Snipped ----'
>>
>> Set myfolder = myNameSpace.Folders("Inbox").Folders("Test")
>> Set myItems = myFolder.Items
>>
>> Msgbox myItems.count  ' returns 5 (mail items)
>>
>> ' first attempt to find an mailitem
>> strFind = "[FlagStatus]=" & olNoFlag
>> Set myItem = myItems.Find(strFind)    '-> myItem = Nothing !!!
>> MsgBox myItem.Subject
>>
>>
>> ' second attempt to find an mailitem
>> strFind = "[FlagIcon]=" & olNoFlagIcon
>> Set myItem = myItems.Find(strFind)   '-> myItem = Nothing !!!
>> MsgBox myItem.Subject
>>
>> '---- end snipped ----'
>>
>> What am I missing here!?
>>
>> Cheers,
>> PascalB
>>
>>
>>
>>
>>
>>
>>
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:uec0bMvGIHA.3980@TK2MSFTNGP03.phx.gbl...
>> I don't understand where you're stuck, since your original code gave the
>> close to the right syntax for using Items.Find to find items with a
>> FlagStatus property equal to the Outlook constant olNoFlag. You need to
>> make
>> just two changes in that, one of which we've already discussed -- how to
>> use
>> the FlagStatus property in a query string. The other change is that you
>> need
>> an explict Items collection, this:
>>
>>    Set myItems = myFolder.Items
>>    strFind = "[FlagStatus]=" & olNoFlag
>>    Set myItem = myItems.Find(strFlag)
>>
>> Repeat with FindNext as many times as you need. Or use Restrict instead
>> of
>> Find to return an Items collection that you can iterate with a For Each
>> ...
>> Next loop. Doing a search on FlagIcon would be almost identical, except
>> that
>> the value would be the one appropriate for red flags.
>>
>> If you still feel stuck, tell us specifically what is stumping you.
>>
>> --
>> Sue Mosher, Outlook MVP
>>   Author of Microsoft Outlook 2007 Programming:
>>     Jumpstart for Power Users and Administrators
>>    http://www.outlookcode.com/article.aspx?id=54
>>
>>
>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>> news:O6TUppsGIHA.4228@TK2MSFTNGP02.phx.gbl...
>>> Hi,
>>>
>>> I know where to find every property, event and function by pressing
>>> <ALt-F11> + <F2> to open the object browser, but i don't know how to
>>> translate these properties into a find function....
>>>
>>> I also know you want to help me by letting me figured everting out by my
>>> own.... I respect that.
>>> I'm not some student who's looking for an easy way out.
>>>
>>> I'm totally stuck on this problem, and that's is why I'm consulting this
>>> newsgroup.
>>>
>>> Let me explain the entire project;
>>> Some college's in the administration department needed some
>>> custom-functions
>>> to examen a certain email folder.
>>>
>>> Short;
>>>
>>> Function 1:
>>> The mails that are in this folder and are not marked; from these emails
>>> I
>>> had to take the subject and insert these into an excel-sheet.
>>> Once this is done, the mails are flagged whit an red flagicon.
>>>
>>> Function 2:
>>> The mails who are now flagged with a red flagicon, must be forwarded to
>>> a
>>> certain person, which is mentioned in the subject of the email.
>>> Once these mails have been send, the original mail-messages is checked
>>> again
>>> as completed.
>>>
>>>
>>> The only problem is that I must loop thru every mail messages to see
>>> which
>>> messages are marked.
>>> Otherwise these function work properly, without any problem... execpt
>>> the
>>> time and processor consuming thingy.
>>>
>>>
>>> PascalB
>>>
>>>
>>>
>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>> news:e3dhdqkGIHA.3768@TK2MSFTNGP06.phx.gbl...
>>> When in doubt about the exact names of properties, check the object
>>> browser:
>>> Press ALt+F11 to open the VBA environment in Outlook, then press F2.
>>> Switch
>>> from <All Libraries> to Outlook to browse all Outlook objects and their
>>> properties, methods, and events.
>>>
>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>> news:egJT%23MkGIHA.3548@TK2MSFTNGP06.phx.gbl...
>>>> Hi,
>>>>
>>>> Could you give me a example to do so?
>>>> I'm stuck and don't have a clue where to start....
>>>>
>>>> Which property "[xxx]" should I give in the Find function?
>>>> Where can I find every possible property that I can use in the Find
>>>> function?
>>>>
>>>> I wouldn't ask you this if the folder where I should find these
>>>> mailitems
>>>> wasn't so big.
>>>> The current script loops thru every +1000 mailitems to find the 20
>>>> items
>>>> that aren't flagged. (time and processor consuming function)
>>>> So that's why I want to narrow down the result by using "Find" and
>>>> "FindNext"
>>>>
>>>>
>>>> TIA.
>>>> PascalB
>>>>
>>>>
>>>>
>>>>
>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>>> news:%237d1A8jGIHA.284@TK2MSFTNGP02.phx.gbl...
>>>>> Could this be done be a simple search and find; perhaps some kind of
>>>>> filter
>>>>> or query!?
>>>>
>>>> Yes, that's what the Items.Find and .Restrict methods are for.
>>>
>>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>>> news:%233iIcCjGIHA.1316@TK2MSFTNGP02.phx.gbl...
>>>>> Hi,
>>>>>
>>>>> Thanks for the reply, but I'll probably stick with the "for each"
>>>>> script
>>>>> I
>>>>> already have to go thru all my items.
>>>>>
>>>>> I know that the given example wasn't real VBA script, it was only
>>>>> mentioned
>>>>> to clear out the problem.
>>>>>
>>>>> Could this be done be a simple search and find; perhaps some kind of
>>>>> filter
>>>>> or query!?
>>>>
>>>>>
>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>>>>> news:ueXDWciGIHA.936@TK2MSFTNGP06.phx.gbl...
>>>>> I always think it's a good idea to create the query string with a
>>>>> separate
>>>>> statement, so you can test the result:
>>>>>
>>>>>    strFind = "[Flagstatus]=""&olNoFlag&"
>>>>>    MsgBox strFind
>>>>>
>>>>> In this case, that would give you a query string of
>>>>>
>>>>>    [Flagstatus]="&olNoFlag&
>>>>>
>>>>> which isn't going to find anything at all. First of all, FlagStatus is
>>>>> an
>>>>> enumerated property, not a string. Second, the & characters are used
>>>>> in
>>>>> your
>>>>> expression as string literals not concatenation operator. So, you're
>>>>> close,
>>>>> but not quite there. This would be the query expression that includes
>>>>> the
>>>>> actual value of olNoFlag:
>>>>>
>>>>>    strFind = "[Flagstatus]=" & olNoFlag
>>>>>
>>>>> To use AdvancedFind in a script, you'd need a loop with a timer to add
>>>>> a
>>>>> delay to allow the search to complete. I'd stick to Find and Restrict.
>>>>>
>>>>> "PascalB" <pascal.bourgeoi***@Mtransics.com.> wrote in message
>>>>> news:enxfUMgGIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>>>> Hi,
>>>>>>
>>>>>> Looking thru the help file and MSDN, I wasn't able to find an example
>>>>>> to
>>>>>> find messages by flagstatus.
>>>>>> The only examples I found are looping thru the entire folder.
>>>>>>
>>>>>> I need to find only certain mailitems who are not flagged, or the
>>>>>> Flagicon
>>>>>> is Red.
>>>>>>
>>>>>> For example, i need
>>>>>> Set myItem = myFolder.Items.Find("[Flagstatus]=""&olNoFlag&")
>>>>>>
>>>>>> I know it is possible to search certain mailitems by using "Advanced
>>>>>> find",
>>>>>> but how do you do this by script?
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> PascalB
>>
>>
>
>

AddThis Social Bookmark Button