Barclay Berger
Posts: 16
Joined: 2009-01-15
|
I want to check if outlook is offline when outlook opens and when they click a button on my addin, too often I have users who bring their notebooks home and open outlook when offline and don't know how to get it back online even after I've told them 100 times. Is there way to check this, I found something about seeing if can open public folders but the example I found I could not get to work in c#. Thanks |
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Hi Barclay,
Please see NameSpace.Offline (Outlook 2002-2007) and NameSpace.ExchangeConnectionMode (Outlook 2003-2007).
Andrei Smolin
Add-in Express Team Leader |
|
Christopher Cardinal
Posts: 133
Joined: 2005-05-17
|
is this an ms exchange environment? if so, the outlook namespace object has the ExchangeConnectionMode property - this prop may have the value of Disconnected or Offline (see enum OlExchangeConnectionMode). |
|
Christopher Cardinal
Posts: 133
Joined: 2005-05-17
|
argh - Andrei beat me to it...
the forum is cachng posts again! |
|
Barclay Berger
Posts: 16
Joined: 2009-01-15
|
I was doing it this way which is shorter but have switched to new suggestion but not sure which is better??
Old Way:
Outlook.MAPIFolder publicFolders = (Outlook.MAPIFolder)OutlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
if (publicFolders == null)
{
MessageBox.Show("2You are not connected to the Exchange Server, please make sure you are working online" + "\n" + "Check lower right hand corner of Outlook for your connection status", "Outlook is Offline", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
New Way:
switch (OutlookApp.Session.ExchangeConnectionMode)
{
case Microsoft.Office.Interop.Outlook.OlExchangeConnectionMode.olNoExchange:
{
MessageBox.Show("You are not connected to the Exchange Server, please make sure you are working online" + "\n" + "Check lower right hand corner of Outlook for your connection status", "Outlook is Offline", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false;
}
case Microsoft.Office.Interop.Outlook.OlExchangeConnectionMode.olCachedOffline:
{
MessageBox.Show("You are not connected to the Exchange Server, please make sure you are working online" + "\n" + "Check lower right hand corner of Outlook for your connection status", "Outlook is Offline", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false;
}
case Microsoft.Office.Interop.Outlook.OlExchangeConnectionMode.olOffline:
{
MessageBox.Show("You are not connected to the Exchange Server, please make sure you are working online" + "\n" + "Check lower right hand corner of Outlook for your connection status", "Outlook is Offline", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false;
}
} |
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Hi Barclay,
The second way is better as it will not produce any unwanted results. The unwanted results might be (requires verification): a login dialog if your old code initiates connecting to Exchange and a delay when accessing Public Folders on a dial-up connection.
Hi Christopher,
This wasn't a case of caching as you posted in just two minutes after me. :)
Andrei Smolin
Add-in Express Team Leader |
|
Barclay Berger
Posts: 16
Joined: 2009-01-15
|
thanks, that makes sense. Appreciate the help |
|