Board index » delphi » Using WildCards in FInd method in items collection

Using WildCards in FInd method in items collection

hey all iv been tring to find out how to use the find method to all of the
contact
that thier last name start with the letter "A", i havnt managed to find out
how to do this, or if it could be done.
i see in the documentation that find method only returnes an item and not a
collection of items
so i guess i cant use this method.

id appriciate any help
daniel.

 

Re:Using WildCards in FInd method in items collection


<<Daniel Shrem:
hey all iv been tring to find out how to use the find
method to all of the contact that thier last name start
with the letter "A"

Quote

Outlook's Find method is pretty limited, but you can do
this, I think:

var
  Items: _Items;
  Disp: IDispatch;
  CI: ContactItem;
  Contacts: MAPIFolder;
begin
  Memo1.Clear;
  Items :=
NmSpace.GetDefaultFolder(olFolderContacts).Items;
  Disp := Items.Find('[Last Name] >= "A" and [Last Name] <
"B"');
  while Assigned(Disp) do
  begin
    if Supports(Disp, ContactItem, CI) then
      Memo1.Lines.Append(CI.FullName);
    Disp := Items.FindNext;
  end;

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Using WildCards in FInd method in items collection


well thankx a lot for ur help but that also did work, i tried that, the
method only iterrates once even though there r more results...
i realy dont understand this methods behavior, also the sort fnction isnt
working good

"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> wrote in
message news:VA.00000b02.001c9612@cableinet.co.not-this-bit.uk...

Quote
> <<Daniel Shrem:
> hey all iv been tring to find out how to use the find
> method to all of the contact that thier last name start
> with the letter "A"

> Outlook's Find method is pretty limited, but you can do
> this, I think:

> var
>   Items: _Items;
>   Disp: IDispatch;
>   CI: ContactItem;
>   Contacts: MAPIFolder;
> begin
>   Memo1.Clear;
>   Items :=
> NmSpace.GetDefaultFolder(olFolderContacts).Items;
>   Disp := Items.Find('[Last Name] >= "A" and [Last Name] <
> "B"');
>   while Assigned(Disp) do
>   begin
>     if Supports(Disp, ContactItem, CI) then
>       Memo1.Lines.Append(CI.FullName);
>     Disp := Items.FindNext;
>   end;

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Using WildCards in FInd method in items collection


<<Daniel Shrem:
the method only iterrates once even though there r more
results...

Quote

Have you tried /exactly/ what I wrote? The use of an Items
variable is essential. If you merely access it through a
property, e.g. Folder.Items, the search will start at the
beginning every time, with the result you describe.

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Using WildCards in FInd method in items collection


<<Daniel Shrem:
the method only iterrates once even though there r more
results...

Quote

Have you tried /exactly/ what I wrote? The use of an Items
variable is essential. If you merely access it through a
property, e.g. Folder.Items, the search will start at the
beginning every time, with the result you describe.

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Using WildCards in FInd method in items collection


ouch, i havnt thought of that ...thankx its working fine.

"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> wrote in
message news:VA.00000b64.0008bb48@cableinet.co.not-this-bit.uk...

Quote
> <<Daniel Shrem:
> the method only iterrates once even though there r more
> results...

> Have you tried /exactly/ what I wrote? The use of an Items
> variable is essential. If you merely access it through a
> property, e.g. Folder.Items, the search will start at the
> beginning every time, with the result you describe.

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Other Threads