How do I count the number of accounts present in Microsoft Outlook 2010?
I'm trying to count number of accounts present in outlook. For the first time it shows count = 0 as there is no account configured in Outlook.
Then I configure an account and tried to count the number of accounts configured within the same appliction. It shows zero every time but when I restart the application and the account is still configured then it shows 1. Strange outcome, it should show count = 1 without restarting the application.
This is my code
OutLook.Application Objoutlook = null;
OutLook.NameSpace objns = null;
OutLook.Accounts objaccounts = null;
Objoutlook = new OutLook.Application();
objns = Objoutlook.GetNamespace("MAPI");
// The Namespace Object (Session) has a collection of accounts.
objaccounts = Objoutlook.Session.Accounts;
messagebox.show (objaccounts.count);
Plz reply it's urgent