none
How to find if Outlook is offline in a VSTO Outlook AddIn (Outlook 2010)? RRS feed

  • Question

  • Our AddIn requires to set a user property to mail items, very frequently. The save operation, after setting a user property is very slow for IMAP accounts, when Outlook is online. So, we are programatically setting Outlook to go offline.

    But, when we try to programatically come online again, Outlook takes some time to come online. We wrote a loop, to wait until Outlook is online.

    while (Application.Session.Offline)
    {
         System.Threading.Thread.Sleep(POLLING_INTERVAL); // sleep and check again.                                
    }

    But, the problem here is that Application.Session.Offline does not indicate the correct offline status. It's set to false, even before Outlook has gone online. The loop does not serve the intended purpose.

    Please provide us ways to deal with this situation. Some pointers to API in Outlook, that reflects the exact offline status would be perfect.

    Thanks in advance for helping us out. :)



    • Edited by Rakesh Gopal Monday, July 1, 2013 2:16 PM Loop was misspelled.
    Monday, July 1, 2013 2:14 PM

Answers

All replies

  • How are you setting the online/offline state?

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

    Monday, July 1, 2013 2:25 PM
  • This is roughly the code we are using to toggle the offline status:

    Office._CommandBars cmdBars = exp.CommandBars;
    cmdBars.ExecuteMso("ToggleOnline");


    • Edited by Rakesh Gopal Monday, July 1, 2013 6:16 PM Some formatting
    Monday, July 1, 2013 6:14 PM
  • If you simulate a mouse click on the button, the sync state changes asynchronously.

    If you were using MAPI, you could use the IMAPIOfflineMgr interface (http://msdn.microsoft.com/en-us/library/office/aa203838(v=office.11).aspx) and call IMAPIOfflineMgr::SetCurrentState method specifying the MAPIOFFLINE_FLAG_BLOCK.


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

    Monday, July 1, 2013 7:02 PM
  • Thank you very much for your time Dmitry. But, we are developing this AddIn for Outlook 2010 and not Outlook 2003. And looks like the interface you mentioned about is not available with the Outlook 2010 API.

    Can you please point me to a similar interface for Outlook 2010? Or is there a way to get the same interface to work on Outlook 2010 API? We knew about this interface. But, somehow figured out that it was not available for Outlook 2010.

    Thanks again for your time and efforts in helping us out.

    Tuesday, July 2, 2013 10:51 AM
  • It is very much available in Outlook 2010. It was first introduced in Outlook 2003.

    You can plain with in in OutlookSpy - click IMAPIOfflineMgr  button.


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

    Tuesday, July 2, 2013 1:27 PM