Solved

Outlook 12 Object Library Compatibility with Office 2003

Posted on 2009-03-31
17
687 Views
Last Modified: 2013-11-25
I have an Access Database I have been working on in Office 2007.  One component is the capability to email a report which required the Outlook 12 Object Libarry to work with the Outlook.Application function in VB.

When I tested the database on Office 2003 which many users still have, the Outlook 12 Object Library fails and causes all sorts of errors.  This is the only place I'm having a problem with reverse compatibility and hope someone has an idea of how to resolve.
0
Comment
Question by:ClearYourSix
  • 7
  • 7
  • 3
17 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24028959
Hi ClearYourSix,

When working with 2003 change to the Outlook 11 Object Library


Good Luck!

Gary
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24028963
Hello ClearYourSix,

When I automate one Office app from another, I *always* use late binding, which usually papers over these
differences.

If you post your code we Experts can give more specific guidance.  Late binding, in a nutshell:

1) You do not set references to the external library
2) Instead of strongly typing the outside object variables, you declare them as type Object
3) You use CreateObject to instantiate the outside Application, and then use that application variable
as the "root" to tap into the external object model

Regards,

Patrick
0
 

Author Comment

by:ClearYourSix
ID: 24029020
There are over 500 users.  So, the solution I need is something that involves no intervention.  When I look at VB References, I don't have the choice to select Object 11 in addition to Object 12.  See code below.  

When I deleted the reference to Outlook 12, the email capability quit working.  It only works when i have explicitly selected it in the VB Reference Library.  Code is below that originally worked with the Object Library.  
On Error GoTo Err_EMAILIndividual_Click
 

strEmailTo = Forms![Agency Business Plan]![Email_Alias]

strDate = Forms![Agency Business Plan]![Report_Date]
 

DoCmd.OpenReport "Agency Business Plan Report (Agent)", acViewPreview

DoCmd.OutputTo acOutputReport, "Agency Business Plan Report (Agent)", "Snapshot Format", "C:\TEMP\Business Plan Report.snp"
 
 

Dim objOutlook As Outlook.Application

Dim objOutlookMsg As Outlook.MailItem

Dim objOutlookRecip As Outlook.Recipient

Dim objOutlookAttach As Outlook.Attachment
 

   ' Create the Outlook session.

   Set objOutlook = CreateObject("Outlook.Application")

   ' Create the message.

   Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

   With objOutlookMsg

   ' Add the To recipient(s) to the message. Substitute

   ' your names here.

   Set objOutlookRecip = .Recipients.Add(strEmailTo)

   objOutlookRecip.Type = olTo

   ' Set the Subject, Body, and Importance of the message.

   .Subject = "RESULTS: Business Plan Report - " & strDate

   .Body = "Here is your most current business plan report." & vbCrLf & vbCrLf

   .Sensitivity = olPrivate

   ' Add attachments to the message.

   If Not IsMissing(AttachmentPath) Then

   Set objOutlookAttach = .Attachments.Add("C:\TEMP\Business Plan Report.snp")

   End If

   ' Resolve each Recipient's name.

   For Each objOutlookRecip In .Recipients

         If Not objOutlookRecip.Resolve Then

         objOutlookMsg.Display

         End If

         Next

   .Send

   End With

   Set objOutlookMsg = Nothing

   Set objOutlook = Nothing

   Set objOutlookRecip = Nothing

   Set objOutlookAttach = Nothing

   

Kill ("c:\temp\business plan report.snp")

DoCmd.Close acReport, "Agency Business Plan Report (Agent)", acSaveNo

DoCmd.Maximize

Forms("Agency Business Plan").SetFocus

   
 

Exit_EMAILIndividual_Click:

    Exit Sub

Err_EMAILIndividual_Click:

    MsgBox Err.Description

      DoCmd.Close acReport, "Agency Business Plan REport (Agent)", acSaveNo

    DoCmd.Maximize

    Forms("Agency Business Plan").SetFocus

   

   End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029044
You can add the 2003 Object to your PC from somebody that has 2003
0
 

Author Comment

by:ClearYourSix
ID: 24029071
tbsgadi:  

How do I get it from them?  The database was originally developed in 2003 and when I switched to 2007, it automatically wiped out the Outlook 11 reference and replaced it with Outlook 12.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029086
You're just copying the tlb/dll file to your PC
0
 

Author Comment

by:ClearYourSix
ID: 24029131
when I do that and pull it in, where it carry then to office 2003 users or at least stay active?  if so and office 2007 is later installed, will they need to reinstall tool so Outlook 12 is picked up?
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029160
If you have the 2003 library it upgrades to 2007 - not the other way around
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:ClearYourSix
ID: 24029176
I think I can make that work.  How do I ADD a reference to the library that doesn't show up in the list already?
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029195
You press the browse button & go to the msoutl.olb file
0
 

Author Comment

by:ClearYourSix
ID: 24029216
OK, give me a few hours to track down that file and test it.  Thanks.  Will get back to you tbsagdi.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029222
Good Luck!
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24029484
Converting to late binding, so that you need *no references* to Outlook...
On Error GoTo Err_EMAILIndividual_Click
 
strEmailTo = Forms![Agency Business Plan]![Email_Alias]
strDate = Forms![Agency Business Plan]![Report_Date]
 
DoCmd.OpenReport "Agency Business Plan Report (Agent)", acViewPreview
DoCmd.OutputTo acOutputReport, "Agency Business Plan Report (Agent)", "Snapshot Format", "C:\TEMP\Business Plan Report.snp"
 
 
Dim objOutlook As Object 'Outlook.Application
Dim objOutlookMsg As Object 'Outlook.MailItem
Dim objOutlookRecip As Object 'Outlook.Recipient
Dim objOutlookAttach As Object 'Outlook.Attachment
 
   ' Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   ' Create the message.
   Set objOutlookMsg = objOutlook.CreateItem(0)  'olMailItem
   With objOutlookMsg
   ' Add the To recipient(s) to the message. Substitute
   ' your names here.
   Set objOutlookRecip = .Recipients.Add(strEmailTo)
   objOutlookRecip.Type = 1   'olTo
   ' Set the Subject, Body, and Importance of the message.
   .Subject = "RESULTS: Business Plan Report - " & strDate
   .Body = "Here is your most current business plan report." & vbCrLf & vbCrLf
   .Sensitivity = 2   'olPrivate
   ' Add attachments to the message.
   If Not IsMissing(AttachmentPath) Then
   Set objOutlookAttach = .Attachments.Add("C:\TEMP\Business Plan Report.snp")
   End If
   ' Resolve each Recipient's name.
   For Each objOutlookRecip In .Recipients
         If Not objOutlookRecip.Resolve Then
         objOutlookMsg.Display
         End If
         Next
   .Send
   End With
   Set objOutlookMsg = Nothing
   Set objOutlook = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing
   
Kill ("c:\temp\business plan report.snp")
DoCmd.Close acReport, "Agency Business Plan Report (Agent)", acSaveNo
DoCmd.Maximize
Forms("Agency Business Plan").SetFocus
   
 
Exit_EMAILIndividual_Click:
    Exit Sub
Err_EMAILIndividual_Click:
    MsgBox Err.Description
      DoCmd.Close acReport, "Agency Business Plan REport (Agent)", acSaveNo
    DoCmd.Maximize
    Forms("Agency Business Plan").SetFocus
   
   End Sub

Open in new window

0
 

Author Comment

by:ClearYourSix
ID: 24029508
tbsgadi... got the Outlook 11 file but was unable to get it to override Outlook 12 Object.  Now trying matthew's code....
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029528
You need to first untick the outlook l2 object & then browse to the 11
0
 

Author Closing Comment

by:ClearYourSix
ID: 31564829
THANK YOU for editing the code.  I had just started to research what you meant by late-binding.  The code works beautifully.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24030219
ClearYourSix,

Glad to help :)

Regards,

Patrick
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now