PC Review


Reply
Thread Tools Rate Thread

accessing contacts in mapifolder way too slow

 
 
=?ISO-8859-1?Q?Kurt_H=E4usler?=
Guest
Posts: n/a
 
      16th Dec 2003
Hi.

I have am using c# and the outlook object model to access the outlook
address book, but once you have more than a 100 or so contacts in the
folder it takes far too long to iterate through them. When theres 3000
contacts in there it takes a whole minute to iterate through them. My
Code is at the end of the post. You can see I have commented out the
dialog box filling section, to see that thats not causing the slowdown,
its the contact = (Outlook.ContactItem) contactItems.Item (counter);
that seems to be slowing things down.

I know it can be done faster because Outlook itself gets all contacts in
its window instantly, and if one uses the mapi32.dll from c++ for
example with MAPILogonEx , OpenAddressBook, and IAddrBook::Address the
contacts appear instantly too. (I cant do this however as I dont want
the default outlook supplied UI)

Any suggestions as to a quicker way to get the contacts in?

Heres my code, its pretty standard copied out of the newsgroups stuff:

private void
GetInfo ()
{
string contactFolderName;
string entryIdFolder;
string entryIdStore;
Outlook.MAPIFolder contactsFolder;
Outlook.Items contactItems;
Outlook.ContactItem contact;

Outlook.NameSpaceClass nameSpace =
(Outlook.NameSpaceClass) oa.GetNamespace ("mapi");
nameSpace.Logon (Environment.UserName, "", true, true);

// Here we need to let the user choose a folder.

//contactsFolder = nameSpace.PickFolder();
try
{
if (Application.UserAppDataRegistry.GetValue ("ContactsFolder") !=
null)
{
// Bits related to registry reading snipped
contactsFolder =
nameSpace.GetFolderFromID (entryIdFolder, entryIdStore);
}
else
{
contactsFolder =
nameSpace.GetDefaultFolder (Outlook.OlDefaultFolders.
olFolderContacts);
}
}
// Catch snipped
contactItems = contactsFolder.Items;

int counter = 0;

ContactPicker cp = new ContactPicker ();

for (counter = 1; counter <= contactItems.Count; counter++)
{


contact = (Outlook.ContactItem) contactItems.Item (counter);
//message = contact.FullName;
//System.Windows.Forms.MessageBox.Show(message);
//contact.Display(true);
/*
ListViewItem newItem = new ListViewItem(contact.FullName,
counter-1);

newItem.SubItems.Add(contact.MailingAddressPostalCode);
newItem.SubItems.Add(contact.MailingAddressCity);
newItem.SubItems.Add(contact.MailingAddressStreet);
newItem.SubItems.Add(contact.BusinessTelephoneNumber);
newItem.SubItems.Add(contact.HomeTelephoneNumber);
newItem.SubItems.Add(contact.MobileTelephoneNumber);
newItem.SubItems.Add(contact.BusinessFaxNumber);

cp.lstContacts.Items.Add(newItem);
//Console.WriteLine(contact.FullName);
*/

}


cp.lstContacts.Sorting = System.Windows.Forms.SortOrder.Ascending;
cp.lstContacts.Sort ();

cp.Show ();

nameSpace.Logoff ();

contactItems = null;
contactsFolder = null;
nameSpace = null;
oa = null;


//return null;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Vista Windows Contacts and Outlook Contacts using c# mrabie Microsoft C# .NET 0 6th Feb 2008 10:53 AM
Accessing contacts in a different folder called "Work Contacts" =?Utf-8?B?Q2hhcmxpZQ==?= Microsoft Access VBA Modules 1 30th Apr 2006 06:47 AM
IE slow accessing IIS6 versus being fast accessing IIS4 =?Utf-8?B?dmFkaW0=?= Windows XP Internet Explorer 0 20th Oct 2004 08:51 PM
IE slow when accessing IIS6 versus fast accessing IIS4 =?Utf-8?B?dmFkaW0=?= Windows XP Internet Explorer 0 20th Oct 2004 08:49 PM
accessing contacts in mapifolder way too slow =?ISO-8859-1?Q?Kurt_H=E4usler?= Microsoft C# .NET 0 16th Dec 2003 09:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:16 PM.