none
How to identify that outlook is online mode or offline mode RRS feed

  • Question

  • Hello All,

    Is there any event or function which tell me that outlook client is offline mode or online mode ?

    or is there any event fire when user switch between online and offline mode ?

    Thanks.


    Sanjay Patel

    Tuesday, June 28, 2016 2:03 PM

Answers

  • Hi,

    I think _NameSpace.Offline property is easier.

                Microsoft.Office.Interop.Outlook.NameSpace nmS;
                nmS =Globals.ThisAddIn.Application.GetNamespace("MAPI"); // i am testing in VSTO add-in
                if (nmS.Offline)
                {
                    System.Windows.Forms.MessageBox.Show("Offline");
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Online");
                }


    • Marked as answer by Sanjay Patel Wednesday, June 29, 2016 1:01 PM
    Wednesday, June 29, 2016 12:15 PM
    Moderator

All replies

  • 1. Outlook Object Model - NameSpace.ExchangeConnectionMode (read-only, only works because the connection mode will be offline if "Work Offline" is clicked).

    2. Extended MAPI (C++ or Delphi only) - IMAPIOfflineMgr::GetCurrentState (you can see it in OutlookSpy - click IMAPIOfflineMgr button).

    3. Redemption (any language) - RDOSession.Offline (read/write).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by Sanjay Patel Wednesday, June 29, 2016 5:44 AM
    • Unmarked as answer by Sanjay Patel Wednesday, June 29, 2016 9:58 AM
    Tuesday, June 28, 2016 3:03 PM
  • Hello Dmitry,


    I checked with first option (Outlook Object Model - NameSpace.ExchangeConnectionMode).


    It will always give me NSpace.ExchangeConnectionMode = OlExchangeConnectionMode.olNoExchange. Whatever i click on offline mode or not.

    I'm checking on Outlook 2016 client and Exchange 2016.

    here is my code

                   var app = new Microsoft.Office.Interop.Outlook.Application();
                    Microsoft.Office.Interop.Outlook.NameSpace NSpace = app.GetNamespace("MAPI");

                   if(NSpace.ExchangeConnectionMode == OlExchangeConnectionMode.olNoExchange)

                   return true;

                 else

                  return false;

    what is wrong or is something missing here ?


    Thanks, Sanjay Patel ------------

    Wednesday, June 29, 2016 10:05 AM
  • Hi,

    I think _NameSpace.Offline property is easier.

                Microsoft.Office.Interop.Outlook.NameSpace nmS;
                nmS =Globals.ThisAddIn.Application.GetNamespace("MAPI"); // i am testing in VSTO add-in
                if (nmS.Offline)
                {
                    System.Windows.Forms.MessageBox.Show("Offline");
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Online");
                }


    • Marked as answer by Sanjay Patel Wednesday, June 29, 2016 1:01 PM
    Wednesday, June 29, 2016 12:15 PM
    Moderator
  • Change OlExchangeConnectionMode.olNoExchange to OlExchangeConnectionMode.olCachedOffline.

    olNoExchange represents the account doesn't use an exchange server

    olCachedOffline represents the account is using exchange mode and the user has selected work offline.

    Wednesday, June 29, 2016 12:34 PM
    Moderator