Solved

Outlook contacts to ListView- code is slow!

Posted on 2012-04-09
7
239 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
  • 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now