Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Posts
    85
    Provided Answers: 2

    Exclamation Answered: Missing Object Library for MS Outlook

    One of my users found this issue with my database.

    I have created a command button whereby a user can send an email to a recipient from within MS Access. Works great on my test system and most other users, but on some it doesn't. Comes down to the fact that some users are using different versions of MS Outlook so the MS Outlook 14 Object library isn't on their system.

    I've done some investigating and found that the issue may be resolved by using Late Binding and removing the reference completely, however I can't figure out how to do this. I've found some solutions to similar issues with Excel and different versions of Outlook, but haven't been able to get them to work for me.

    Could some kind person possibly advise on how I can resolve this?

    The code for the command button is here

    Code:
    Private Sub SendMail_Click()
        EmailAddr = [EmailAddress]
        Call SendMail1
    End Sub
    and the routine to call Outlook and start an email is here

    Code:
    Sub SendMail1()
    
    Dim objOutlook As Outlook.Application
    Dim objEmailItem As MailItem
    
    ' prevent 429 error if Outlook is not already open
    On Error Resume Next
    Err.Clear
    Set objOutlook = GetObject(, "Outlook.application")
    
    If Err.Number <> 0 Then
    Set objOutlook = New Outlook.Application
    End If
    
    Set objEmailItem = objOutlook.CreateItem(olMailItem)
    With objEmailItem
    .To = EmailAddr
    .Display
    End With
    Set objEmailItem = Nothing
    Set objOutlook = Nothing
    End Sub

  2. Best Answer
    Posted by sheusz

    "
    Quote Originally Posted by ranman256 View Post
    In the VBE screen, Tools, References,
    Uncheck the OUtlook that says MISSING, and check the Outlook that exists.
    Hi Ranman256
    Your suggestion is what I tried first, however it doesn't solve the problem if users with different versions of Outlook are simultaneously sharing the database. In the end I got my code to work. Now it doesn't matter what version or Outlook the end user is using. I've tried the database on various systems (XP with Outlook 2007 and Win 8 with Outlook 14) and it works fine.

    If you are interested here is the code.
    Code:
    Sub SendMail1()
    
    Dim appOutLook As Object
    Dim MailOutLook As Object
    
    Const olMailItem As Long = 0
    
    ' prevent 429 error if Outlook is not already open
    On Error Resume Next
    Err.Clear
    Set appOutLook = GetObject(, "Outlook.application")
    If Err.Number <> 0 Then
    Set appOutLook = GetObject(, "Outlook.Application")
    End If
    
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    
    With MailOutLook
    .To = EmailAddr
    .Display
    End With
    End Sub
    The only issue that remains is that if Outlook isn't open when the email command is executed the mail goes to the Outbox and is not automatically sent. If Outlook is open then all works fine. It's not a real problem because all the users tend to have Outlook open all the time anyway."


  3. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    In the VBE screen, Tools, References,
    Uncheck the OUtlook that says MISSING, and check the Outlook that exists.
    I had to do this for various people.

    (Even had to direct them over the phone)
    If you know their version, you could build a macro/code to do it for them.
    But it CANNOT run if the wrong outlook is checked. It would have to have NO outlooks checked, then run the macro to load.

  4. #3
    Join Date
    Sep 2010
    Posts
    85
    Provided Answers: 2
    Quote Originally Posted by ranman256 View Post
    In the VBE screen, Tools, References,
    Uncheck the OUtlook that says MISSING, and check the Outlook that exists.
    Hi Ranman256
    Your suggestion is what I tried first, however it doesn't solve the problem if users with different versions of Outlook are simultaneously sharing the database. In the end I got my code to work. Now it doesn't matter what version or Outlook the end user is using. I've tried the database on various systems (XP with Outlook 2007 and Win 8 with Outlook 14) and it works fine.

    If you are interested here is the code.
    Code:
    Sub SendMail1()
    
    Dim appOutLook As Object
    Dim MailOutLook As Object
    
    Const olMailItem As Long = 0
    
    ' prevent 429 error if Outlook is not already open
    On Error Resume Next
    Err.Clear
    Set appOutLook = GetObject(, "Outlook.application")
    If Err.Number <> 0 Then
    Set appOutLook = GetObject(, "Outlook.Application")
    End If
    
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    
    With MailOutLook
    .To = EmailAddr
    .Display
    End With
    End Sub
    The only issue that remains is that if Outlook isn't open when the email command is executed the mail goes to the Outbox and is not automatically sent. If Outlook is open then all works fine. It's not a real problem because all the users tend to have Outlook open all the time anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •