Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,

In My Application, I am loading Outlook Contacts to my generic list on startup, and I have more than 2000 contacts in my list (It takes atleast 4 minutes to load all the contacts).
The problem is, When the user try to open the Outlook Application, while these contact fetching is going on... It shows this Error....

"sorry we're having trouble starting outlook. only one version of outlook can run at a time. Check to see if another version of outlook is running, or try restarting your computer"

How to get rid of it... Please Tell me Urgent. This is my code fetching the contacts...

C#
Outlook.Application app = new Outlook.Application();
                     Outlook.NameSpace ns = app.GetNamespace("MAPI");
                     Outlook.MAPIFolder contacts =
                     ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

                     for (int i = 1; i < contacts.Items.Count + 1; i++)
                     {
                         //Adding COntacts to a Generic List
                     }
Posted
Updated 1-Sep-16 5:56am
Comments
[no name] 31-Jul-13 7:31am    
Nope.... I checked. It's not urgent at all. Get rid of what? The error message? Outlook? The user? The running instance of Outlook? Why are you not checking for a running instance of Outlook?
Yesudasan Moses 31-Jul-13 7:37am    
I meant, When the user opens the original Outlook APplication for sending mails,,, It wont start,,, It will show the error.. I think only one instance is permitted for Outlook... But I have to fetch contact though,,, May be it will take minutes depending on the count of contacts..
Any alternative methode for fetching contacts without hurting the user's needs ??
Richard MacCutchan 31-Jul-13 8:05am    
Tell the user to wait until your application has finished loading; you have no other choice.

Perhaps you can use Exchange Web Services (EWS) instead of using the Outlook client because the only way to get around your issue is for the user to wait. The error is clear about that.

There is an example here:
http://chrisrisner.com/Programmatically-Accessing-Outlook-Contacts-Via-Exchange-Web-Services[^]
 
Share this answer
 
v2
Comments
Maciej Los 31-Jul-13 9:03am    
Good suggestion.
+5!
See mine ;)
ZurdoDev 31-Jul-13 9:07am    
That is good. I think in this case his code is already running and then the user is kicking off Outlook but since his code was already running they get the error.
Try to get existing instance of MS Outlook before you create new one.

How to: Get and Log On to an Instance of Outlook[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900