Solved

Outlook contacts to ListView- code is slow!

Posted on 2012-04-09
7
246 Views
Last Modified: 2012-05-14
i am trying to get my Outlook contacts to display in a listview.

Using the code below, it takes some time to get just 150 contacts (where I am testing the app).

Any suggestions for making this go faster?

Code:

             Dim TempStr() As String
            Dim TempNode As ListViewItem
            Dim TempArr() As ListViewItem
            Dim i As Integer

 

            ReDim TempStr(6)
 
            objAddressList = _
                   objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

            'Get all the contacts

            Dim itm As New ListViewItem
            Dim strOutlookInfo(10) As String

            objItems = objAddressList.Items

            For j = 1 To objItems.Count

                If objItems(j).class = 40 Then
                     TempStr(0) = objItems(j).entryid
                    TempStr(1) = objItems(j).title
                    TempStr(2) = objItems(j).firstname
                    TempStr(3) = objItems(j).middlename
                    TempStr(4) = objItems(j).lastname
                    TempStr(5) = objItems(j).suffix
                    TempStr(6) = objItems(j).email1address

                    TempNode = New ListViewItem(TempStr)
                    TempNode.Tag = objItems(j).entryid

                    ReDim Preserve TempArr(i)
                    TempArr(i) = TempNode
 
                    i += 1

                End If
             Next

             lvwOutlook.Items.AddRange(TempArr)
0
Comment
Question by:scbdpm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37827596
If this is a Windows Forms ListView, the first thing to try is to use ListView.BeginUpdate before loading, and ListView.EndUpdate after.  This prevents the control from drawing, while items are loaded.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37832919
I bet the slowness is in communication between your app and Outlook and there is nothing you can do about that. You may want to try something else like CDO to interact with Outlook instead of managed API but I am not sure how much difference it would make performancewise.
0
 

Author Comment

by:scbdpm
ID: 37833441
CodeCruise,
I think you are correct as I did some experimenting with timing and it was more on the 'grab from Outlook' side than  the actually load ListView.

Not familiar with CDO. can you direct me to some info?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 96

Expert Comment

by:Bob Learned
ID: 37833850
How much time does it take to get 150 contacts?
0
 

Author Comment

by:scbdpm
ID: 37833857
about 4-5 seconds.... but that is my home outlook and I'd like to use for my work outlook of 350+...
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37834352
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37834554
I wonder if Redemption suffers from the same problem.  That is what I use, and there is an interface to get IRDOContactItem information.

Redemption is a free download for developers, which a fee for deployment licenses.

Download Redemption
http://www.dimastr.com/redemption/download.htm

C# example as a proof-of-concept:

            RDOFolder contactsFolder = this.redemptionSession.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);

            List<OutlookContact> contactList =
                contactsFolder.Items
                    .OfType<RDOContactItem>()
                    .Select(x => new OutlookContact(x))
                    .ToList();

            return contactList;

Open in new window

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question