2
Reply

How do I count the number of accounts present in Microsoft Outlook 2010?

sabir Hussain

sabir Hussain

Jul 18 2011 6:06 AM
1.2k
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


Answers (2)