[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 559
  • Last Modified:

Outlook API is slow

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
Jan Vojtech Vanicek
Asked:
Jan Vojtech Vanicek
  • 10
  • 6
  • 5
  • +1
1 Solution
 
Berkson WeinTech FreelancerCommented:
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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
...and I have the same exchange account connected to the all computers...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
Berkson WeinTech FreelancerCommented:
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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
Berkson WeinTech FreelancerCommented:
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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
Miguel OzSoftware EngineerCommented:
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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
DaveCommented:
If you are using cached code try deleting the OST file.
0
 
DaveCommented:
Sorry and re-create. If the contacts folder content changes a lot might be worth turing off cached mode.
0
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
g4ugm: I had to try create complete new user profile with new outlook settings - so it is not user related...
0
 
Berkson WeinTech FreelancerCommented:
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
 
DaveCommented:
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
 
Berkson WeinTech FreelancerCommented:
The OP already indicated that he doesn't have any AV on this machine...
0
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
DaveCommented:
It might just still be worth checking what plugins are loaded...
0
 
Berkson WeinTech FreelancerCommented:

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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
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
 
Miguel OzSoftware EngineerCommented:
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
 
Jan Vojtech VanicekIT SpecialistAuthor Commented:
Yes, thats it! Thank you!
0

Featured Post

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!

  • 10
  • 6
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now