I'm developing an add-in for Outlook using C# and Add-in Express. I wonder if is possible to set Outlook to work offline programmatically from the add-in itself. Looking for a solution i've found only a way to know programmatically if Outlook is set in offline mode or not. I would accept a solution that use only Outlook VSTO add-in as well if is not possible to solve this problem using only add-in express.
Add-in Express (nor VSTO) doesn't provide anything for that. Also the Outlook Object Model doesn't let you do this - the Namespace.Offline
property is read-only. It looks like Redemption allows setting up their RDOSession.Offline
property. Be aware, the Offline
property returns valid information only for an Exchange profile. It is not intended for non-Exchange account types such as POP3, IMAPI, and HTTP.
Don't forget that users may click the Work Offline
button on the ribbon which also changes the Offline
property of the Namespace class. So, from your add-in you can execute the ribbon command programmatically by using the CommandBars.ExecuteMso method which executes the control identified by the idMso parameter. This method is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons
, toggleButtons
, and splitButtons
. The required idMso
value of the control is ToggleOnline
. For example, your code might look like that:
Application.CommandBars.ExecuteMso("ToggleOnline");