Results 1 to 13 of 13

Microsoft Outlook Object Library 16.0

  1. #1
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71

    Microsoft Outlook Object Library 16.0


    I am developing a database and when I install the program on a user's pc who is using an earlier version of office or access, I get the error message"object or library cannot be found" . Having done some research I found that the object reference to Outlook is missing on the other user's pc. I can select outlook object from the VBA editor on their pc and the program works. However if I deploy an update the same error occurs. Is there code I can put in place to check the outlook reference on the users pc to avoid this error? Thanks again for your help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    17,532
    Use late binding, which doesn't require a reference:

    http://www.granite.ab.ca/access/latebinding.htm
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    This is what I have seen but where do I put the code in my application? Sorry to ask.

  4. #4
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    Simple for experts, but how do I close the objects in the code example in the link?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    17,532
    Probably no differently

    Set VariableName = Nothing

    If closing is appropriate

    VariableName.Close
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  6. #6
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    Where do I put this code, just for future reference?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    17,532
    The bulk of that code was not necessary, the key is the different way the variables are declared and set. Perhaps this one is clearer:

    https://support.microsoft.com/en-us/...-in-automation
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  8. #8
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    Thanks for this. My database is spilt and placed in a network folder. So sorry for being dim but really don't understand from the examples that have been shown. I will obviously try things tomorrow and see how I get on. Code examples work well for me with an idiot's guide included lol. Thanks again.

  9. #9
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    Quote Originally Posted by pbaldy View Post
    The bulk of that code was not necessary, the key is the different way the variables are declared and set. Perhaps this one is clearer:

    https://support.microsoft.com/en-us/...-in-automation
    I am still unsure as to where this code should be placed in my application and how it is called when i install the program on another PC.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    17,532
    You would be tweaking your existing code, not adding anything new. You would also uncheck the Outlook reference so you wouldn't get the error on other computers.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  11. #11
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    Quote Originally Posted by pbaldy View Post
    You would be tweaking your existing code, not adding anything new. You would also uncheck the Outlook reference so you wouldn't get the error on other computers.
    I agree and i have tried a few tweaks with no success. the code i currently use is that if the email in the code does not exist in the Outlook mail list then the email is sent through the default Outlook account of the user. This where i fall down. There is a call to a Public Function contained in a module and i don't know how to work around this and still achieve the same result. All suggestions welcome.

    *Email Code below*

    Public Sub SendSerialEmail()


    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Dim emailTo As String
    Dim emailSubject As String
    Dim emailText As String
    Dim acc As Outlook.Account


    Dim outApp As Outlook.Application
    Dim outMail As Outlook.MailItem
    Dim outlookStarted As Boolean


    On Error Resume Next
    Set outApp = GetObject(, "Outlook.Application")
    On Error GoTo 0
    If outApp Is Nothing Then
    Set outApp = CreateObject("Outlook.Application")
    outlookStarted = True
    End If


    Set db = CurrentDb
    Set rs = db.OpenRecordset("SELECT FirstName, Surname, EmailAddress, DeskVacated, VacateDesk " & _
    " FROM qryPGRDesks1FilterAll")
    Do Until rs.EOF


    'emailTo = Trim(rs.Fields("FirstName").Value & " " & rs.Fields("Surname").Value) & _
    " <" & rs.Fields("EmailAddress").Value & ">"
    emailTo = Trim(rs.Fields("EmailAddress").Value)

    emailSubject = "Notification to vacate desk"
    If IsNull(rs.Fields("FirstName").Value) Then
    emailSubject = emailSubject & " for " & _
    rs.Fields("FirstName").Value & " " & rs.Fields("Surname").Value
    End If

    emailText = Trim("Hi " & rs.Fields("FirstName").Value) & vbCrLf & vbCrLf
    'If rs.Fields("DeskVacated").Value Then
    'emailText = emailText & "Here is a special offer only for VIP customers!" & _
    '"Only this month: Get the foo widget half price!" & vbCrLf
    'End If

    emailText = emailText & _
    "This email is to inform you that your desk needs to be vacated on " & rs.Fields("VacateDesk").Value & "." & " " & _
    "Please contact the Faculty Infrastucture Team should you need to discuss this request." & " " & _
    "Our email address is EZ-faculty-services <EZ-faculty-services@exmail.nottingham.ac.uk> " & vbCrLf & vbCrLf & _
    "Best Regards " & vbCrLf & vbCrLf & _
    "Faculty Infrastructure Team - Desk Allocation" & vbCrLf & _
    "Extension Number: 00000 "



    Set outMail = outApp.CreateItem(olMailItem)
    Set acc = GetAccountByEmail(outApp, "EZ-faculty-services@exmail.nottingham.ac.uk")
    If Not acc Is Nothing Then
    outMail.SendUsingAccount = acc
    End If

    'Set outMail = outApp.CreateItem(olMailItem)
    'outMail.SendUsingAccount = GetAccountByEmail(outApp, "EZ-jhtest@exmail.nottingham.ac.uk")
    outMail.To = emailTo
    outMail.Subject = emailSubject
    outMail.Body = emailText
    outMail.Send


    rs.MoveNext
    Loop

    rs.Close
    Set rs = Nothing
    Set db = Nothing

    If outlookStarted Then
    outApp.Quit
    End If

    Set outMail = Nothing
    Set outApp = Nothing

    End Sub

    *Public Function Code below*

    Public Function GetAccountByEmail(ByRef outlApp As Outlook.Application, ByVal strSenderEmail As String) As Outlook.Account


    Dim acc As Outlook.Account
    Dim retVal As Outlook.Account

    For Each acc In outlApp.Session.Accounts
    If acc.SmtpAddress = strSenderEmail Then
    Set retVal = acc
    Exit For
    End If
    Next acc

    Set GetAccountByEmail = retVal


    End Function

  12. #12
    hinchi1 is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    71
    having sat down and looked at my initial question i have not solved the problem and now understand more about early and late binding. thanks for all your feedback as always. one last question, how do i set this post to solved?

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    17,532
    Now solved or not solved? If you've got late binding working, you can mark the thread solved in Thread Tools at the top of the thread.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Microsoft Office 14.0 Object Library
    By MatthewR in forum Programming
    Replies: 4
    Last Post: 07-29-2016, 09:05 AM
  2. Replies: 7
    Last Post: 11-13-2014, 06:46 AM
  3. Missing Object library and .dll
    By tmcrouse in forum Forms
    Replies: 1
    Last Post: 06-23-2014, 05:17 PM
  4. Replies: 1
    Last Post: 09-03-2011, 06:01 PM
  5. Replies: 5
    Last Post: 07-15-2011, 11:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums