Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Outlook contacts to ListView- code is slow!

Posted on 2012-04-09
7
Medium Priority
?
247 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

705 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