View Single Post
  #4  
Old January 24th 07, 03:00 PM posted to microsoft.public.outlook.program_vba
jeanluc
external usenet poster
 
Posts: 9
Default Exchange Server availability

Again me. I have tested around some solutions but I always have my problem.

Here the beginning of the code :

Set myOlApp = CreateObject("Outlook.Application") ' line 1
Set myNamespace = myOlApp.GetNamespace("MAPI") ' line 2
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox) ' line 3

When the program comes to the line 3, it brings me the popup Your
Microsoft Exchange Server is unavailable / Retry - Work Offline - Cancel
(wenn answering Retry to this popup, the program continue normally and
connect to Exchange)

I have inserted between line 2 and 3 following code, in order to give time
to the process to connect to exchange (stupid idea, perhaps ?) :

Open gsLogFile For Append As #1
nb_retry = 1
While myNamespace.ExchangeConnectionMode = olNoExchange _
Or myNamespace.ExchangeConnectionMode = olDisconnected _
Or myNamespace.ExchangeConnectionMode = olCachedDisconnected
PauseTime = 60
Start = Timer
Do While Timer Start + PauseTime
DoEvents
Loop
Print #1, "Dump " & myNamespace.ExchangeConnectionMode & " - check " &
nb_retry & " - " & Now
nb_retry = nb_retry + 1
If nb_retry 60 Then
GoTo end_main
End If
Wend
Close #1

Result : I always got 60 lines of dump in my logfile.
myNamespace.ExchangeConnectionMode never got another value then 0.
And it jump to the end of the program.

Any other idea, perhaps ?
Thanks and regards.

Jean-Luc
**********
"jeanLuc" wrote:

Thanks. I will try this and watch the behaviour of my scheduled job.
Rgrds
JL

"Eric Legault [MVP - Outlook]" wrote:

Try checking the value of NameSpace.ExchangeConnectionMode. You should
always be able to retrieve a valid Outlook.Application object though,
regardless of what it is trying to connect to or it's connection state. You
didn't show all of your code so I don't know exactly what you are trying to
do or when.

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"jeanLuc" wrote:

I have some code I use to handle mail messages (Outlook 2003) with VB/VBA as
follows:

Dim objOutlook As Outlook.Application
Set objOutlook = CreateObject("Outlook.Application")
etc....

The code works fine except when the Exchange Server is unavailable (Popup
message Your Microsoft Exchange Server is unavailable / Retry - Work Offline
- Cancel)

Is it possible, programmatically (VB or VBA), to check the availability of
the Exchange Server before using Outlook features ?

Thanks a lot. Regards.

Jean-Luc

Ads