Solved

Outlook API is slow

Posted on 2010-09-04
23
519 Views
Last Modified: 2012-05-10
Hi There,
my program written in VS2005 is accessing outlook contacts etc... Week ago I have start getting slower.

When im getting items of ContactItems collection, Im calling that function: (in code section)

Before the slowdown, its not problem to load cca 2000 contacts in few seconds, but now - its one second per contact! And Outlook proces utilizing CPU to 100% while Im loading contacts...

Its Outlook 2003 connected to Exchange Server by RPC over HTTPS. Im using also MapiLab plugin "Advanced Security 1.51", but Im using it for long time without problems.

I have tested it on other computers and there is no problem...

Whats wrong?
Private Function GetEmailAddress(ByVal Person as ContactItem) As String

With Person



Dim GEA As String = ""



If .Email3AddressType = "SMTP" Then

GEA = .Email3Address

End If



If .Email2AddressType = "SMTP" Then

GEA = .Email2Address

End If



If .Email1AddressType = "SMTP" Then

GEA = .Email1Address

End If



End With

End Function

Open in new window

0
Comment
Question by:Vanikcz
  • 10
  • 6
  • 5
  • +1
23 Comments
 
LVL 15

Expert Comment

by:weinberk
Comment Utility
I know you said you've tried it on other computers, but have you tried it with this user account on other machines?
Might you try recreating the Outlook profile on the troubled machine or do other user profiles work quickly?  
Are you used cached mode?
 
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
I have tried to create new outlook profile - with one POP3 account and some contacts by hand - its the same...

Its not domain environment, but I had not try to delete user profile - I will try it...

Yes Im using cached mode.
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
...and I have the same exchange account connected to the all computers...
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
Now, I was created a new user profile on the same computer. After synchronisation of whole mailbox the situation is the same... It is extremely slow...
0
 
LVL 15

Expert Comment

by:weinberk
Comment Utility
OK, so we know it's not the user account since the same account works elsewhere.
Just so that I'm sure I understand, it doesn't matter if you have a couple of contacts or thousands, it still takes around a second per contact?
Are other outlook functions slow?
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
Other functions eg. loading the outlook folders hierarchy is working smoothly.

I found this:
http://blogs.msdn.com/b/akashb/archive/2008/08/26/8897650.aspx

but its another cup of tea... He is going thru 10,000 contacts in two minutes...

I have profile where the contacts have 300 items - it takes around three or four minutes and second profile has 2900 items - really I dont want to know how long it is loading... :-D It doesnt matter - if there are two items in the folder the loading of one takes the same time as folder with 3000 items.

Im pretty sure that is not a hardware issue - Its Intel U2500@ 1,2GHz with 2GB of RAM. Disk isnt overloaded durning the loading and the windows that Im using are freshly installed - two weeks. There is only Win XP SP3, Office 2003 SP3, Visual Studio 2005, Office 2003 PIA and Advanced Security.

Im using this machine only to compiling this program for compatibility Office 2003 - 2007 - 2010, there is no antivirus software or something like this...
0
 
LVL 15

Expert Comment

by:weinberk
Comment Utility
These are all really good points that you bring up.
You wrote that a week ago it started getting "slower."  Has it gotten worse in the last couple of days?  
Have you tried starting outlook in safe mode?  If that works, it's not a permanent fix, just one that might help us find the cause.
Can you step through the code (set a breakpoint and then step) to see if you can pinpoint the line that's taking so long?
 
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
Im not sure about the time when it started...

In the safe mode it is the same

Lines within the posted function:
6, 10, 14, 15

Emal1Address is used only... So its every access to ContactItem...
0
 
LVL 35

Expert Comment

by:Miguel Oz
Comment Utility
My educated guess is to compare:
- windows hotfixes/updates that your development PC has had compared with say the time you think it was working OK and also it will help to compare with what other computers have. Unfortunately a hotfix/update may produce this issue, then after some complaining M$ will fix it in the next update.
- Hardware like memory, free disk space., virtual memory, etc.

Also,  I notice is that your call employ far too many property call methods
- replace "SMTP" with a constant. No point of creating a new string every time
- Why having a pure if logic. (What about the code below)

If .Email3AddressType = "SMTP" Then
GEA = .Email3Address
End If

Else If .Email2AddressType = "SMTP" Then
GEA = .Email2Address
End If

Else
GEA = .Email1Address
End If
thus you minimize COM calls (every property call is a COM call to Outlook, expensive...)
- are you forcing the the garbage collector to clean up your variables. (You are processing a lot of contacts and sometimes COM objects may still exist, put this code at start/end of your loop:
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
Note:the reason is called two times is to get rid of any second generation object.

If you need more help, please post your loop code
 
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
I can imagine that the code can be optimized, but it takes place from 10000 contacts. In my point this isnt important... i can optimize the code of 0.3 sec by operation, but on another pc it is uncomparable faster - it is the same unoptimized code...
Thank you for valuable tips, but my problem is now in some hotfix or something - as you say...

To if logic:what if email1 is only set and it isnt the smtp type? its rare, but... also if there is more email addresses, i want that with less number, im not sure how elseif is working but i think that there cant run multiple branches...
0
 
LVL 12

Expert Comment

by:Dave
Comment Utility
If you are using cached code try deleting the OST file.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

by:Dave
Comment Utility
Sorry and re-create. If the contacts folder content changes a lot might be worth turing off cached mode.
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
g4ugm: I had to try create complete new user profile with new outlook settings - so it is not user related...
0
 
LVL 15

Expert Comment

by:weinberk
Comment Utility
What I has asked was for you to step through the code to see where it's being slow on this machine.  Is there a single line that's taking the second to complete or is it just slower overall.  If there's just one line where the trouble is, then we can try to step backwards to see what changes could be causing that specific issue.
 
0
 
LVL 12

Expert Comment

by:Dave
Comment Utility
This may be a red herring, but which AntVirus (if any) do you have. I have seen this cause issues. You can often unload the AV plugin in Tools, Options , Other Tab, Advanced.
0
 
LVL 15

Expert Comment

by:weinberk
Comment Utility
The OP already indicated that he doesn't have any AV on this machine...
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
weinberk: it is slow on each line - when Im stepping by F11 on each line where Im reading something form ContactItem object, there is little, but feelable freeze, other lines are executed immediately.  So loading of one contact takes a littlebit over one second (I think that object is accessed 4 times) - I doesnt measure it, but is really big difference form other machines...
0
 
LVL 12

Expert Comment

by:Dave
Comment Utility
It might just still be worth checking what plugins are loaded...
0
 
LVL 15

Expert Comment

by:weinberk
Comment Utility

Other options:
 
1) Try running Outlook in safe mode - not a fix, but if it works here it'll be helpful to know
2) use ccleaner (www.ccleaner.com) clean all of the temporary stuff out and do a registry cleanup (under tools I think it is).  That probably won't do much, BUT it should make your machine run better in general
3) Uninstall and reinstall office including all of its patches
4) Try a new account.  I'm not talking about another email account, I'm talking about creating a fresh administrator account on the machine (or domain) and trying from there
5) Do a repair from Office
0
 
LVL 6

Author Comment

by:Vanikcz
Comment Utility
Its hints that I had completed already with no success. Now I tried to run it in computer, where it wasnt run yet. Its running well until I install MAPILabs Advanced Security. So the cause is clear... But do you know any way to get rid of the "allow access" window, when Im working with contacts in Outlook 2003?
0
 
LVL 12

Expert Comment

by:Dave
Comment Utility
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
Comment Utility
Ok, I was close to the mark . In this case your add-in MAPILabs Advanced Security is interfering with your code.
You need to buy:
http://www.add-in-express.com/outlook-security/?mapilab

See the sample codes on how to disable it:
Dim SecurityManager As New AddinExpress.Outlook.SecurityManager  
SecurityManager.DisableOOMWarnings = True  
Try  
    ' ... Your code here...  
Finally  
    ' In any case please remember to turn on  
    ' Outlook Security after your code,  
    ' since now it is very easy to switch it off! :-)  
    SecurityManager.DisableOOMWarnings = False  
End Try  
0
 
LVL 6

Author Closing Comment

by:Vanikcz
Comment Utility
Yes, thats it! Thank you!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Resolve DNS query failed errors for Exchange
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

762 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

9 Experts available now in Live!

Get 1:1 Help Now