+ Reply to Thread
Results 1 to 2 of 2

Re: Outlook 11 > Outlook 10 Object Library Compatibility Issues

  1. #1
    DW
    Guest

    Re: Outlook 11 > Outlook 10 Object Library Compatibility Issues

    Thanks for your post ... this should resolve a similar problem that I am
    having ...

    I've put the following Function together:

    Sub TestSendEmailLateBinding()
    Dim bResult As Boolean
    Dim arto(1) As String
    Dim arcc(1) As String
    Dim sto As String
    Dim sCC As String


    arto(0) = "[email protected]"
    arto(1) = "[email protected]"
    arcc(0) = "[email protected]"
    arcc(1) = "[email protected]"
    bResult = SendEmailLateBinding("c:\output.log", arto, "Subject test",
    "body test", arcc)


    sto = "[email protected]"
    sCC = "[email protected]"
    bResult = SendEmailLateBinding("c:\output.log", sto, "Subject test", "body
    test", sCC)


    End Sub



    Function SendEmailLateBinding(sInPathFile As String, sInTo As Variant, _
    sInSubject As String, sInBody As String, Optional sInCC As Variant) As
    Boolean
    Dim bResult As Boolean
    Dim sResp As String
    Dim obApp As Object
    Dim obEmail As Object 'Outlook.MailItem
    Dim obFiles As Object 'Outlook.Attachments
    Dim obRecipients As Object 'Outlook.Recipients
    Dim obRecipient As Object 'Outlook.Recipient
    Dim iTo As Integer
    Dim iCC As Integer
    Dim bCont As Boolean

    Set obApp = CreateObject("Outlook.Application")
    Set obEmail = obApp.CreateItem(0) '0=olMailItem
    Set obRecipients = obEmail.Recipients

    On Error Resume Next
    iTo = UBound(sInTo)

    If Err <> 0 Then
    Set obRecipient = obEmail.Recipients.Add(sInTo)
    Err.Clear
    Else
    For iTo = 0 To UBound(sInTo)
    Set obRecipient = obEmail.Recipients.Add(sInTo(iTo))
    Next iTo
    End If
    obRecipient.Type = 1 '1=to; 2=cc
    bCont = True

    iCC = UBound(sInCC)

    If Err <> 0 Then
    Set obRecipient = obEmail.Recipients.Add(sInCC)
    Err.Clear
    Else
    For iCC = 0 To UBound(sInCC)
    Set obRecipient = obEmail.Recipients.Add(sInTo(iCC))
    Next iCC
    End If
    obRecipient.Type = 2 '1=to; 2=cc
    bCont = True
    On Error GoTo 0


    If bCont Then
    obEmail.Subject = sInSubject
    obEmail.Body = sInBody

    If sInPathFile <> "" Then
    obEmail.Attachments.Add sInPathFile, 1 '1=olByValue
    End If

    'send email
    On Error Resume Next
    obEmail.Send

    If Err > 0 Then
    sResp = MsgBox("Email to " & sInTo & " has not been sent." & _
    Chr(10) & "Err: " & Err.Description & _
    Chr(10) & "Do you want the program to continue?", vbYesNo)

    If sResp = 6 Then
    bResult = True
    Else
    bResult = False
    End If

    Err.Clear
    Else
    bResult = True
    End If
    On Error GoTo 0
    End If
    SendEmailLateBinding = bResult
    End Function


    "Bob Phillips" wrote:

    > Paul,
    >
    > Try using late binding.
    >
    > Instead of a declaration like
    >
    > Dim olApp as Outlook.Application
    >
    > use
    >
    > Dim olApp As Object
    >
    > all other Outlook objects should be defined as Objects as well
    >
    > and instantiate it like this
    >
    > Set olApp = CreateObject("Outlook.Application")
    >
    > rather than
    >
    > Set olApp = New Outlook.Application
    >
    > You will need to use values rather than Outlook constants as well.
    >
    > There is a web page describing this at
    > xldynamic.com/source/xld_Early_Late.html
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    > ... looking out across Poole Harbour to the Purbecks
    > (remove nothere from the email address if mailing direct)
    >
    > "Paul Mac" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi All,
    > >
    > > I'm having a porblem with a workbook that uses the Outlook Object Library

    > (MSOUTL.olb). In particular, the wb has references to the Version 10 file.
    > Now that a new computer on the network has Version 11, it is causing a few
    > incompatibility issues.
    > >
    > > In particular, when the workbook, is saved on the machine that is sporting

    > OL2003 it saves the references to OLB version 11. When a user on version 10
    > opens the file, the reference is missing, as "C:\Program Files\Microsoft
    > Office\Office11\MSOUTL.olb" does not exist only "..Office10\MSOUTL.olb"
    > >
    > > I've never had this sort of problem with version changes from 2000-2, so

    > what is the cause.
    > >
    > > Will copying the library onto the local machine resolve the issue or is

    > this not advisable.
    > >
    > > Your advice on this one is greatly appreciated.
    > >
    > > Paul Mac.

    >
    >
    >


  2. #2
    DW
    Guest

    Re: Outlook 11 > Outlook 10 Object Library Compatibility Issues

    And an improved version:


    Function SendEmailLateBinding(sInPathFile As String, sInTo As Variant, _
    sInSubject As String, sInBody As String, Optional sInCC As Variant) As
    Boolean
    Dim bResult As Boolean
    Dim sResp As String
    Dim obApp As Object
    Dim obEmail As Object 'Outlook.MailItem
    Dim obFiles As Object 'Outlook.Attachments
    Dim obRecipients As Object 'Outlook.Recipients
    Dim obRecipient As Object 'Outlook.Recipient
    Dim iTo As Integer
    Dim iCC As Integer
    Dim bCont As Boolean

    Set obApp = CreateObject("Outlook.Application")
    Set obEmail = obApp.CreateItem(0) '0=olMailItem
    Set obRecipients = obEmail.Recipients

    On Error Resume Next
    iTo = UBound(sInTo)

    If Err <> 0 Then
    Set obRecipient = obEmail.Recipients.Add(sInTo)
    Err.Clear
    Else
    For iTo = 0 To UBound(sInTo)
    Set obRecipient = obEmail.Recipients.Add(sInTo(iTo))
    Next iTo
    End If
    obRecipient.Type = 1 '1=to; 2=cc
    bCont = True

    If Not IsMissing(sInCC) Then
    iCC = UBound(sInCC)

    If Err <> 0 Then
    Set obRecipient = obEmail.Recipients.Add(sInCC)
    Err.Clear
    Else
    For iCC = 0 To UBound(sInCC)
    Set obRecipient = obEmail.Recipients.Add(sInTo(iCC))
    Next iCC
    End If

    obRecipient.Type = 2 '1=to; 2=cc
    bCont = True
    End If
    On Error GoTo 0


    If bCont Then
    obEmail.Subject = sInSubject
    obEmail.Body = sInBody

    If sInPathFile <> "" Then
    obEmail.Attachments.Add sInPathFile, 1 '1=olByValue
    End If

    'send email
    On Error Resume Next
    obEmail.Send

    If Err > 0 Then
    sResp = MsgBox("Email to " & sInTo & " has not been sent." & _
    Chr(10) & "Err: " & Err.Description & _
    Chr(10) & "Do you want the program to continue?", vbYesNo)

    If sResp = 6 Then
    bResult = True
    Else
    bResult = False
    End If

    Err.Clear
    Else
    bResult = True
    End If
    On Error GoTo 0
    End If
    SendEmailLateBinding = bResult
    End Function




    "DW" wrote:

    > Thanks for your post ... this should resolve a similar problem that I am
    > having ...
    >
    > I've put the following Function together:
    >
    > Sub TestSendEmailLateBinding()
    > Dim bResult As Boolean
    > Dim arto(1) As String
    > Dim arcc(1) As String
    > Dim sto As String
    > Dim sCC As String
    >
    >
    > arto(0) = "[email protected]"
    > arto(1) = "[email protected]"
    > arcc(0) = "[email protected]"
    > arcc(1) = "[email protected]"
    > bResult = SendEmailLateBinding("c:\output.log", arto, "Subject test",
    > "body test", arcc)
    >
    >
    > sto = "[email protected]"
    > sCC = "[email protected]"
    > bResult = SendEmailLateBinding("c:\output.log", sto, "Subject test", "body
    > test", sCC)
    >
    >
    > End Sub
    >
    >
    >
    > Function SendEmailLateBinding(sInPathFile As String, sInTo As Variant, _
    > sInSubject As String, sInBody As String, Optional sInCC As Variant) As
    > Boolean
    > Dim bResult As Boolean
    > Dim sResp As String
    > Dim obApp As Object
    > Dim obEmail As Object 'Outlook.MailItem
    > Dim obFiles As Object 'Outlook.Attachments
    > Dim obRecipients As Object 'Outlook.Recipients
    > Dim obRecipient As Object 'Outlook.Recipient
    > Dim iTo As Integer
    > Dim iCC As Integer
    > Dim bCont As Boolean
    >
    > Set obApp = CreateObject("Outlook.Application")
    > Set obEmail = obApp.CreateItem(0) '0=olMailItem
    > Set obRecipients = obEmail.Recipients
    >
    > On Error Resume Next
    > iTo = UBound(sInTo)
    >
    > If Err <> 0 Then
    > Set obRecipient = obEmail.Recipients.Add(sInTo)
    > Err.Clear
    > Else
    > For iTo = 0 To UBound(sInTo)
    > Set obRecipient = obEmail.Recipients.Add(sInTo(iTo))
    > Next iTo
    > End If
    > obRecipient.Type = 1 '1=to; 2=cc
    > bCont = True
    >
    > iCC = UBound(sInCC)
    >
    > If Err <> 0 Then
    > Set obRecipient = obEmail.Recipients.Add(sInCC)
    > Err.Clear
    > Else
    > For iCC = 0 To UBound(sInCC)
    > Set obRecipient = obEmail.Recipients.Add(sInTo(iCC))
    > Next iCC
    > End If
    > obRecipient.Type = 2 '1=to; 2=cc
    > bCont = True
    > On Error GoTo 0
    >
    >
    > If bCont Then
    > obEmail.Subject = sInSubject
    > obEmail.Body = sInBody
    >
    > If sInPathFile <> "" Then
    > obEmail.Attachments.Add sInPathFile, 1 '1=olByValue
    > End If
    >
    > 'send email
    > On Error Resume Next
    > obEmail.Send
    >
    > If Err > 0 Then
    > sResp = MsgBox("Email to " & sInTo & " has not been sent." & _
    > Chr(10) & "Err: " & Err.Description & _
    > Chr(10) & "Do you want the program to continue?", vbYesNo)
    >
    > If sResp = 6 Then
    > bResult = True
    > Else
    > bResult = False
    > End If
    >
    > Err.Clear
    > Else
    > bResult = True
    > End If
    > On Error GoTo 0
    > End If
    > SendEmailLateBinding = bResult
    > End Function
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Paul,
    > >
    > > Try using late binding.
    > >
    > > Instead of a declaration like
    > >
    > > Dim olApp as Outlook.Application
    > >
    > > use
    > >
    > > Dim olApp As Object
    > >
    > > all other Outlook objects should be defined as Objects as well
    > >
    > > and instantiate it like this
    > >
    > > Set olApp = CreateObject("Outlook.Application")
    > >
    > > rather than
    > >
    > > Set olApp = New Outlook.Application
    > >
    > > You will need to use values rather than Outlook constants as well.
    > >
    > > There is a web page describing this at
    > > xldynamic.com/source/xld_Early_Late.html
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > > ... looking out across Poole Harbour to the Purbecks
    > > (remove nothere from the email address if mailing direct)
    > >
    > > "Paul Mac" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi All,
    > > >
    > > > I'm having a porblem with a workbook that uses the Outlook Object Library

    > > (MSOUTL.olb). In particular, the wb has references to the Version 10 file.
    > > Now that a new computer on the network has Version 11, it is causing a few
    > > incompatibility issues.
    > > >
    > > > In particular, when the workbook, is saved on the machine that is sporting

    > > OL2003 it saves the references to OLB version 11. When a user on version 10
    > > opens the file, the reference is missing, as "C:\Program Files\Microsoft
    > > Office\Office11\MSOUTL.olb" does not exist only "..Office10\MSOUTL.olb"
    > > >
    > > > I've never had this sort of problem with version changes from 2000-2, so

    > > what is the cause.
    > > >
    > > > Will copying the library onto the local machine resolve the issue or is

    > > this not advisable.
    > > >
    > > > Your advice on this one is greatly appreciated.
    > > >
    > > > Paul Mac.

    > >
    > >
    > >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1