We help IT Professionals succeed at work.
Get Started

Error Wih GetNameSpace

Last Modified: 2012-07-10
Hello Experts,

The following code snippet (I have not included the whole function) runs from MS Access to text if a user can get to their Outlook inbox. Works across any Access from 2003 to 2010 and with any Outlook from 2003 to 2010. Which version of Access are combined with which versions of Outllok alsodoen't seem to matter as long as references point to the right Outlook version. On one computer (of hundreds) which has Access 2003 and Outlook 2010 the code fails at the highlighted GetNamespace line. Any ideas?


Dim outlookForceStarted As Boolean
Dim objOL As Outlook.Application
Dim oItem As Outlook.MailItem
Dim objNS As NameSpace
outlookForceStarted = False

On Error Resume Next

'see if Outlook is running
errMsg = "Error checking if Microsoft Outlook is running." & vbCrLf & vbCrLf & "A failure at this point can indicate a problem with your Microsoft Outlook installation of a missing VBA reference to the Outlook Object Library."
Set objOL = GetObject(, "Outlook.Application")
If Err <> 0 Then
    'Outlook wasn't running, so start it
    errMsg = "Error starting Microsoft Outlook."
    Set objOL = CreateObject("Outlook.Application")
    outlookForceStarted = True
End If
On Error GoTo mapiTestError

Set objNS = objOL.GetNamespace("MAPI")
Set objfolder = objNS.GetDefaultFolder(olFolderInbox)
Watch Question
Top Expert 2011
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE