none
Check outlook is online RRS feed

  • Question

  • Hello

    I have some codes that executes when user selects a mail in the Inbox mail gridview, each time a web service will call. I’m facing a lagging issue (because web service will fail) when outlook is offline or the system is not connected to internet. How to solve this issue?

    There is any option to check the connection status of outlook? Or is possible test my SOAP service is alive?

    The user selects mail randomly, this would work smoothly that’s my target

    Thanks

    Jenus M

     

    Thursday, October 23, 2014 7:25 AM

Answers

  • Hello Jenus,

    The Outlook object model doesn't provide anything for this. You may consider your VSTO add-in as a regular .Net application where you can do whatever you need - check the internet connection and etc. For example, you can use the InternetGetConnectedState method available in Windows API:

    [DllImport("wininet.dll", CharSet = CharSet.Auto)]
    private extern static bool InternetGetConnectedState(ref InternetConnectionState_e lpdwFlags, int dwReserved);
    
    [Flags]
    enum InternetConnectionState_e : int
    {
       INTERNET_CONNECTION_MODEM = 0x1,
       INTERNET_CONNECTION_LAN = 0x2,
       INTERNET_CONNECTION_PROXY = 0x4,
       INTERNET_RAS_INSTALLED = 0x10,
       INTERNET_CONNECTION_OFFLINE = 0x20,
       INTERNET_CONNECTION_CONFIGURED = 0x40
    }
    
    // In function for checking internet
    InternetConnectionState_e flags = 0;          
    bool isConnected = InternetGetConnectedState(ref flags, 0);

    Or using the Microsoft.VisualBasic assembly classes:

    Network network = new Network();
    return network.IsAvailable;
    

    You can find the following links helpful:

    Fastest way to test internet connection

    check internet connection available or not in c# Finally, I'd suggest asking common programming questions on the Visual C# or Visual Basic forums.

    Thursday, October 23, 2014 7:49 AM
  • While InternetGetConnectedState will give you the network connection state, IMAPIOfflineMgr interface will give you Outlook connection state.

    IMAPIOfflineMgr (being an Extended MAPI interface) is only accessible from C++ or Delphi. You can play with that interface in OutlookSpy (click IMAPIOfflineMgr button).

    In other languages, the interface functionality can be accessed through Redemption, which implements the RDOSession.Offline property (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!



    Thursday, October 23, 2014 2:10 PM

All replies

  • Hello Jenus,

    The Outlook object model doesn't provide anything for this. You may consider your VSTO add-in as a regular .Net application where you can do whatever you need - check the internet connection and etc. For example, you can use the InternetGetConnectedState method available in Windows API:

    [DllImport("wininet.dll", CharSet = CharSet.Auto)]
    private extern static bool InternetGetConnectedState(ref InternetConnectionState_e lpdwFlags, int dwReserved);
    
    [Flags]
    enum InternetConnectionState_e : int
    {
       INTERNET_CONNECTION_MODEM = 0x1,
       INTERNET_CONNECTION_LAN = 0x2,
       INTERNET_CONNECTION_PROXY = 0x4,
       INTERNET_RAS_INSTALLED = 0x10,
       INTERNET_CONNECTION_OFFLINE = 0x20,
       INTERNET_CONNECTION_CONFIGURED = 0x40
    }
    
    // In function for checking internet
    InternetConnectionState_e flags = 0;          
    bool isConnected = InternetGetConnectedState(ref flags, 0);

    Or using the Microsoft.VisualBasic assembly classes:

    Network network = new Network();
    return network.IsAvailable;
    

    You can find the following links helpful:

    Fastest way to test internet connection

    check internet connection available or not in c# Finally, I'd suggest asking common programming questions on the Visual C# or Visual Basic forums.

    Thursday, October 23, 2014 7:49 AM
  • While InternetGetConnectedState will give you the network connection state, IMAPIOfflineMgr interface will give you Outlook connection state.

    IMAPIOfflineMgr (being an Extended MAPI interface) is only accessible from C++ or Delphi. You can play with that interface in OutlookSpy (click IMAPIOfflineMgr button).

    In other languages, the interface functionality can be accessed through Redemption, which implements the RDOSession.Offline property (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!



    Thursday, October 23, 2014 2:10 PM