MAPI StoreID Property - Access Hangs

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

In Access 2002 am using the StoreID propertry, something
basically like this...

Private Sub x()

Dim intStoreID as Integer
Dim olMapi As Outlook.NameSpace
Dim intStoreID As Integer

Set olMapi = CreateObject
("Outlook.Application").GetNamespace("MAPI")
intStoreID = Nz(olMapi.Folders
("Main/Files/Jobs").StoreID, 0)

If intStoreID > 0 Then
(a bunch of code)
End If

Set olMapi = Nothing

End Function

This is working beautifully when the exchange server is
up. Today I discovered that when it's down, calling the
StoreID property sometimes causes Acess to hang. What's
strange it hangs NOT when StoreID is referenced but later -
- when the namespace object is destroyed or at the end of
the sub, whichever comes first.

I have tried many various sequences of commands, and the
StoreID property is the culprit. Leave it in and Access
hangs; take it out and no hanging. I have also tried all
kinds of error trapping without any luck. It seems to
hang about 50% of the time. There no rhyme or reason that
I can discern.

I would be delighted to find some simple way to check to
see if the Exchange server is available before accessing
this property. Any ideas???

Thanks for any help you can give!

Tim Scott
 
Just a guess, but, I don't much like the look of this:
Set olMapi = CreateObject("Outlook.Application").GetNamespace("MAPI")

Try keeping seperate references:

dim oOutlook as object
Set oOutlook = CreateObject("Outlook.Application")
Set olMapi = oOutlook.GetNamespace("MAPI")
...
set olMapi = nothing
set oOutlook = nothing

HTH,
TC
(off for the day)
 
Thanks. I tried what you suggested, and it didn't work,
but did allow me to refine my troubleshooting. Here' what
I found:

Now I am creating the application and the namespace
seperately as you suggested. Upon creating the
application, I can see that "OUTLOOK.EXE" process is
launched. I also see that setting the namespace to
Nothing causes the "OUTLOOK.EXE" process to terminate.

The problem comes when I check for StoreID of a mailbox
that cannot be found. The sytem handles that error just
fine. I give Error -2147221219 - inforamtion store not
found. So far so good. However when I go to setting the
namespace object to Nothing or exit the function, Access
hangs and the "OUTLOOK.EXE" process stays running. If I
manually kill the outlook process in Task Manager, Access
gets un-hung and continues processing just fine.

Probably exiting the function is destroying the namespace
object, so that's where the problem is. I'm guessing that
Access is communicating with Outlook, Outlook is no
responding, and Access can't handle that.

Oh boy. Any more ideas on this one!?!?!

Tim
 
Sorry, I don't have Outlook on this PC, so I can't run any tests myself.

If you post the exact code you are using now, with an indication "in line"
as to where the error occurs, I'll take one more look at it, but there are
no guarantees that I'll be able to suggest anything extra.

Personally, I'd try asking in one of the messaging or Outlook newsgroups.

Good luck,
TC
 
Back
Top