Jump to content
Sign in to follow this  

Outlook Online/Offline

Recommended Posts


I'm trying to port over the following code... It tells you if Outlook is set to Work Offline or not...

$objSession = ObjCreate("MAPI.Session")

$objSession.Logon ("", "", False, False)

$objInfostore = $objSession.GetInfoStore($objSession.Inbox.StoreID)

$bolOffline = $objInfostore.Fields("&H6632000B")

If $bolOffline Then
  MsgBox (0, "", "Online")
  MsgBox (0, "", "Not Online")

The original code is:

MsgBox "Online = " & IsOutlookOnline

Function IsOutlookOnline()

   Dim objSession
   Dim objInfoStore
   Dim bolOffline

   Set objSession = CreateObject("MAPI.Session")

   ' Use the existing Outlook session
   objSession.Logon "", "", False, False

   Set objInfostore = objSession.GetInfoStore(objSession.Inbox.StoreID)

   ' Check if it's offline
   bolOffline = objInfostore.Fields(&H6632000B) 'PR_STORE_OFFLINE

   If bolOffline Then
      IsOutlookOnline = False
      IsOutlookOnline = True
   End If

   Set objInfoStore = Nothing
   Set objSession = Nothing

End Function

What am I doing wrong? Also, does anyone know if there's a way to then change Outlook to being in Work Offline mode and vice versa?

Share this post

Link to post
Share on other sites

This works for me.

Const $PR_STORE_OFFLINE = 0x6632000B

ConsoleWrite(IsOutlookOnline() & @CR)

Func IsOutlookOnline()
    Local $oSession, $oInfoStore, $bOffline

    $oSession = ObjCreate("MAPI.Session")
    ; Use the existing Outlook session
    $oSession.Logon ("", "", False, False)
    $oInfostore = $oSession.GetInfoStore($oSession.Inbox.StoreID)
    ; Check if it's offline
    $bOffline = $oInfostore.Fields($PR_STORE_OFFLINE) ;PR_STORE_OFFLINE
    $oInfoStore = 0
    $oSession = 0
    If $bOffline Then
        Return 0
        Return 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.