Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    create emails causing error on old outlook versions.

    I have come across this problem before and also a solution. Some of the machines here are running a really old version of outlook meaning I get a runtime error when referencing the outlook 15 object library.



    I know there is a way to achieve what I want without referencing any outlook library. I just cant remember what its called. Any advice appreciated.

    here's the code I'm using:

    Code:
    Private Sub Command73_Click()
    
    Dim oApp As Outlook.Application
    Dim oMail As MailItem
    Set oApp = CreateObject("Outlook.application")
    Set oMail = oApp.CreateItem(olMailItem)
    oMail.Body = Me!Site_Name & " " & Me!Asset_Type & vbCrLf & Me!Address_1 & vbCrLf & Me!Address_2 & vbCrLf & Me!Address_3 & vbCrLf & Me!Postcode & vbCrLf & vbCrLf & "Hospital Details:" & vbCrLf & Me!Hospital_Name & vbCrLf & Me!Hospital_Address & vbCrLf & Me!Hospital_Postcode & vbCrLf & "Tel: " & Me!Hospital_Telephone
    oMail.Subject = Me!Site_Name & " Details"
    oMail.To = "test"
    oMail.Display
    AppActivate oMail.Subject
     
    Set oMail = Nothing
    Set oApp = Nothing
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    each PC could have a different version , so you must remove the REFERENCE to the new Outlook, and load reference to the old one.
    unfortunately, this must be done manually.
    or
    keep track of who has what version, have your db use NO reference to outlook, then when the user opens the db, vb code can scan for the version and load it into the references:
    I ran this code to detect if OUTLOOK was loaded (which it shouldnt be to distribute a new version) then it finds it and loads it.

    Code:
    Public Sub Check4Ref()
    Dim bFound As Boolean
    Dim ref
    
    On Error GoTo errRef
    For Each ref In Application.References
       If ref.Name = "OUTLOOK" Then
         bFound = True
         GoTo endit
       End If
        'Debug.Print ref.Name, ref.FullPath
    Next
    
       'add the outlook
    If Not bFound Then Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 1, 0
    endit:
    Exit Sub
    errRef:
    MsgBox "Outlook not found", vbCritical, "Device Fail"
    End Sub

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Hey Ranman, Appreciate your reply there.

    I'm sure there is a way to do this with no references at all but as I said I cant remember what it was or even find anything similar.

    So looks like I'm going to go down the route you described there.

    I have no problem manually assigning references. There are only a few machines ill need to do this for, but. How?

    I can only develop in the new version and it doesn't chow older library's. ( I am going to look this up I was trying to get a more robust code before doing so).

  4. #4
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Late binding! that's what it was haha. I guess ill have to figure that out.

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you can keep your references....just NOT the OUTLOOK one. The code will set it.

  6. #6
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Thanks for the advice.

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

Similar Threads

  1. Importing emails from Outlook
    By Vidraj in forum Access
    Replies: 1
    Last Post: 06-24-2015, 08:38 PM
  2. Sending Emails from Access via Outlook
    By Terry Lawson in forum Programming
    Replies: 3
    Last Post: 11-14-2014, 10:03 AM
  3. Send Emails from outlook
    By WhiskyLima in forum Access
    Replies: 8
    Last Post: 08-11-2014, 11:02 AM
  4. Sending several emails causes Outlook crash
    By mercapto in forum Programming
    Replies: 3
    Last Post: 06-14-2013, 07:30 AM
  5. Linked Outlook emails
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 04-15-2012, 11:16 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
  •  
Other Forums: Microsoft Office Forums