M
mounil
Hi all,
Sorry for cross-posting, but i realied that this is a better place
for my post.
I was trying to add to the Items collection all the items of the Contacts
folder and the all the items of all its subfolders. But was getting the
following
runtime error.
Error:= "Could not complete the operation. One or more parameter values are
not valid"
Then later this is what i found on the MSDN
Add Method (Items Collection) :-
Creates a new Outlook item in the Items collection for the folder, and
returns the new item. If not specified, the Type of the item defaults to the
type of the folder, or to MailItem if the parent folder is not typed.
....which does me no good
I am stumped as to how I can add the already existing contact items into a
collection ( in the position marked {***} ) in the code below (which is
commented out now as it gives an error).
I've added some ShowMessage lines....displaying the number of subfolders in
the default Contacts folder in Outlook and the other ShowMessages display
the number of contact items in each of those subfolders.
The number of items displayed in the last ShowMessage is = to the number
of items in the default Contacts folder.
I am using OL 2000 and programming in Delphi 6.
I would really appreciate if someone can help me out
TIA,
Mounil.
--------------------
begin
try
Outlook := CreateOleObject('Outlook.Application');
NameSpace := Outlook.GetNamespace('MAPI');
DefaultContactFolders := NameSpace.GetDefaultFolder(olFolderContacts);
Contacts:= DefaultContactFolders.Items;
Root := DefaultContactFolders.Parent;
For k := 1 To Root.Folders.count do
begin
if Root.Folders.Item(k).Name = 'Contacts' then
begin
ShowMessage('Number of SubFolders in the Contacts Folder = ' +
IntToStr( DefaultContactFolders.Folders.Count));
for i := 1 to DefaultContactFolders.Folders.Count do
begin
for j := 1 to DefaultContactFolders.Folders(i).Items.Count do
begin
ShowMessage('Number of items in the folder "' +
DefaultContactFolders.Folders(i).Name + '" = ' +
IntToStr(DefaultContactFolders.Folders(i).Items.Count));
//Contacts.Add(DefaultContactFolders.Folders(i).Items(j));{***} {***}
{***}
end;
end;
ShowMessage('Number of items in Contact collection = ' + IntToStr
Contacts.Count));
end;
end;
--------------------
Sorry for cross-posting, but i realied that this is a better place
for my post.
I was trying to add to the Items collection all the items of the Contacts
folder and the all the items of all its subfolders. But was getting the
following
runtime error.
Error:= "Could not complete the operation. One or more parameter values are
not valid"
Then later this is what i found on the MSDN
Add Method (Items Collection) :-
Creates a new Outlook item in the Items collection for the folder, and
returns the new item. If not specified, the Type of the item defaults to the
type of the folder, or to MailItem if the parent folder is not typed.
....which does me no good
I am stumped as to how I can add the already existing contact items into a
collection ( in the position marked {***} ) in the code below (which is
commented out now as it gives an error).
I've added some ShowMessage lines....displaying the number of subfolders in
the default Contacts folder in Outlook and the other ShowMessages display
the number of contact items in each of those subfolders.
The number of items displayed in the last ShowMessage is = to the number
of items in the default Contacts folder.
I am using OL 2000 and programming in Delphi 6.
I would really appreciate if someone can help me out
TIA,
Mounil.
--------------------
begin
try
Outlook := CreateOleObject('Outlook.Application');
NameSpace := Outlook.GetNamespace('MAPI');
DefaultContactFolders := NameSpace.GetDefaultFolder(olFolderContacts);
Contacts:= DefaultContactFolders.Items;
Root := DefaultContactFolders.Parent;
For k := 1 To Root.Folders.count do
begin
if Root.Folders.Item(k).Name = 'Contacts' then
begin
ShowMessage('Number of SubFolders in the Contacts Folder = ' +
IntToStr( DefaultContactFolders.Folders.Count));
for i := 1 to DefaultContactFolders.Folders.Count do
begin
for j := 1 to DefaultContactFolders.Folders(i).Items.Count do
begin
ShowMessage('Number of items in the folder "' +
DefaultContactFolders.Folders(i).Name + '" = ' +
IntToStr(DefaultContactFolders.Folders(i).Items.Count));
//Contacts.Add(DefaultContactFolders.Folders(i).Items(j));{***} {***}
{***}
end;
end;
ShowMessage('Number of items in Contact collection = ' + IntToStr
Contacts.Count));
end;
end;
--------------------