[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Connection state (Offline mode too)

Posted on 2002-04-23
17
Medium Priority
?
486 Views
Last Modified: 2010-05-18
Hi experts, I'm using a VBA macro (Outlook 2000)
and want to find out wether I'm currently connected to
my Exchange Server or not
(including detection if I'm working in Offline mode
without having network problems)
and
if I'm able to establish a connection to
my Exchange Server (network problems, ??).

How can I do that?
A snippet would be very appreciated.

I expect that the same function can be performed
by a Visual Basix program as well.

HStrix
0
Comment
Question by:HStrix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 4
17 Comments
 
LVL 9

Expert Comment

by:rjcpjc
ID: 6963089
This is a VBScript macro, but can be adapted for VBA or VB.

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
Else
     IsOutlookOnline = True
End If

Set objInfoStore = Nothing
Set objSession = Nothing

End Function
0
 

Author Comment

by:HStrix
ID: 6965560
Thank you rjcpjc,
I've incorporated your suggestion as follows:
---
Private Function IsOutlookOnline() As Boolean
Dim objSession   As MAPI.Session ' object
Dim objInfoStore As Object
Dim bolOffline   As Boolean

    Set objSession = CreateObject("MAPI.Session")  ' late binding CDO 2.1

    '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
    Else
        IsOutlookOnline = True
    End If
    Set objInfoStore = Nothing

    Set objSession = Nothing

End Function
---
But after execution of  
"bolOffline = objInfoStore.Fields &H6632000B) 'PR_STORE_OFFLINE"
(called at the beginning of "UserForm_Initialize")
I get the following error:
"Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)"
As you can see the referral to CDO 2.1 exists.
What else is missing?
0
 
LVL 9

Expert Comment

by:rjcpjc
ID: 6966012
Try this code instead:  

bolOffline= objInfoStore.Fields.Item(PR_STORE_OFFLINE).Value
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:HStrix
ID: 6966055
Same error occurred.
?
0
 
LVL 9

Expert Comment

by:rjcpjc
ID: 6966093
Are you sure that CDO is installed?  Its not by default with Outlook 2000.
0
 

Author Comment

by:HStrix
ID: 6966218
My references contain the following entry:
  Microsoft CDO 1.2 Library
  and the path refers to my system's path
  "E:\Program Files\Common Files\System\Mapi\1031\NT\cdo.dll"
  it is dated 1998-06-04 (seems to be service pack 1)
My Outlook's version is 9.0.0.2814
---
Before I referred to CDO I couldn't use
  Dim objSession   As MAPI.Session ' object ' early binding
I had to use
  Dim objSession   As Object                ' lated binding


0
 
LVL 9

Expert Comment

by:rjcpjc
ID: 6966224
Try to run Outlook setup and make sure that CDO is installed there.  I'll keep looking.
0
 

Author Comment

by:HStrix
ID: 6966904
OK, I'll check it next time.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6971598
Do you have offline storage setup on the profile that you are testing with?
0
 

Author Comment

by:HStrix
ID: 6971947
No, I haven't setup an offline storage file.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6972114
Set one up with offline storage configured and try Patricia's code sample again.
0
 

Author Comment

by:HStrix
ID: 6973604
OK, I'll do this check as well.
But is this really necessary to create an ost file?
If I don't have access to my Exchange server,
I automatically work offline too.
Outlook discovers that and shows only my pst file(s).
And I expect that it is possible to find out such a status in generally.
But how?
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6974896
Yes if you want to determine if Outlook 98/2000 (Corp/Workgroup) and Outlook 97/2002 is offline from an Exchange server.

If you are trying to ascertain if a stand-alone user is offline (which they really can't be since they are using a PST), then you would use the Win32API to determine if they have a valid network connection.
0
 

Author Comment

by:HStrix
ID: 6976430
Thank you,
but it is still not fully clear to me.
- Outlook is able to detect if the connection to the Exchange Server exists.
  In such a case Outlook is offering the pst file(s) only.
  My target is, to take over that information from Outlook,
  I'm trying to let Outlook do as much work as possible and collect the current existing information.
  Otherwise I'ld have to read the registry, get the name of the Exchange server and do lots of Win32API calls.
  But why should I do the work again what Outlook has done already?
- Secondly there might exist some suspicious status.
  In such a status Outlook detects this, shows only the pst file(s) and offers a user called "Unknown".
  That also means Outlook does have that information.
  The question is where is it and how can I retrieve it?
0
 
LVL 16

Accepted Solution

by:
Neo_mvps earned 400 total points
ID: 6979080
The sample provided is what you would use to determine if you are online/offline from exchange.  The only problem with the code is that it requires you to have offline configured and working from the profile.

Outside of that, Outlook doesn't supply any properties or methods that one can use to determine what state it is in.  However if you do notice that "Unknown" is being returned in the currentuser property, then you might have a workaround.  (e.g. If unknown is being returned, then you don't have a connection to exchange because mapi couldn't initialize the store.)
0
 

Author Comment

by:HStrix
ID: 6981267
OK, I've implemented a Ping routine.
That helps me getting the proper connection status to the Exchange server.
I think, in a "normal" environment (except for a notebook, ...) nobody will setup an ost file.
The required information for the Ping I'm reading from the registry (HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\).
The result of the Ping I'm using during the further process.
The solution is not as I've expected, but it seems working.

Because of your answers I'ld like to make my question PAQ and share the points between you.
Thank you very much for your help.
But I don't know how to do a sharing.
Perhaps a moderator can help?
0
 

Author Comment

by:HStrix
ID: 7010303
I could solve my problem based on the hints of rjcpjc and Neo_mvps. In addition I used the information offered on "http://www.dimastr.com/redemption/".
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question