Multiple Versions of Outlook

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • musicloverlch

    #1

    Multiple Versions of Outlook

    Hi all,

    I have a database being used by 30 people and is split between the
    backend and frontend. The database has the ability to send e-mails
    through Outlook and I have even put Redemption on people's PCs as to
    not get all the Outlook security prompts. Here's the problem: Half
    are using Outlook 2003, the other half is using Outlook 2007, and 1 is
    using Outlook XP. I am using Outlook 2007, so my reference is set to
    use Microsoft Outlook 12.0, but other people need Outlook 11.0

    Can I programmaticall y have the database detect what type of Outlook
    is on the PC and set the reference accordingly?

    Thanks in advance,
    Laura
  • banem2@gmail.com

    #2
    Re: Multiple Versions of Outlook

    On Nov 19, 5:09 pm, musicloverlch <lho...@gmail.c omwrote:
    Hi all,
    >
    I have a database being used by 30 people and is split between the
    backend and frontend.  The database has the ability to send e-mails
    through Outlook and I have even put Redemption on people's PCs as to
    not get all the Outlook security prompts.  Here's the problem: Half
    are using Outlook 2003, the other half is using Outlook 2007, and 1 is
    using Outlook XP.  I am using Outlook 2007, so my reference is set to
    use Microsoft Outlook 12.0, but other people need Outlook 11.0
    >
    Can I programmaticall y have the database detect what type of Outlook
    is on the PC and set the reference accordingly?
    >
    Thanks in advance,
    Laura
    Hi Laura,

    I know about the issue using different versions of Outlook and usually
    client agree to use only one version. However, here are couple of
    ideas which I didn't try yet, but I think it might work.

    Reference can be set programmaticall y with:

    Application.Ref erences.AddFrom File FileName

    Where FileName is Outlook DLL.

    A better option might be not to use the reference if possible.
    Actually I have found advice some time ago, but I don't know the
    author nor it will work with Outlook. Following solution is for MS
    Word reference:

    -----
    You can declare your word object as a generic object and then use the
    CreateObject method.

    So this

    Dim WordApp as Word.Applicatio n
    Set WordApp = New Word.Applicatio n

    Would become

    Dim WordApp as Object
    Set WordApp = CreateObject("W ord.Application ")
    ----

    This works with Word, as told, but you can give a try with Outlook.

    If you have issues, let me know and I will give a try to make it work.

    Regards,
    Branislav Mihaljev
    Microsoft Access MVP

    Comment

    • banem2@gmail.com

      #3
      Re: Multiple Versions of Outlook

      On Nov 20, 12:42 pm, ban...@gmail.co m wrote:
      On Nov 19, 5:09 pm, musicloverlch <lho...@gmail.c omwrote:
      >
      Hi all,
      >
      I have a database being used by 30 people and is split between the
      backend and frontend.  The database has the ability to send e-mails
      through Outlook and I have even put Redemption on people's PCs as to
      not get all the Outlook security prompts.  Here's the problem: Half
      are using Outlook 2003, the other half is using Outlook 2007, and 1 is
      using Outlook XP.  I am using Outlook 2007, so my reference is set to
      use Microsoft Outlook 12.0, but other people need Outlook 11.0
      >
      Can I programmaticall y have the database detect what type of Outlook
      is on the PC and set the reference accordingly?
      >
      Thanks in advance,
      Laura
      >
      Hi Laura,
      >
      I know about the issue using different versions of Outlook and usually
      client agree to use only one version. However, here are couple of
      ideas which I didn't try yet, but I think it might work.
      >
      Reference can be set programmaticall y with:
      >
      Application.Ref erences.AddFrom File FileName
      >
      Where FileName is Outlook DLL.
      >
      A better option might be not to use the reference if possible.
      Actually I have found advice some time ago, but I don't know the
      author nor it will work with Outlook. Following solution is for MS
      Word reference:
      >
      -----
      You can declare your word object as a generic object and then use the
      CreateObject method.
      >
      So this
      >
      Dim WordApp as Word.Applicatio n
      Set WordApp = New Word.Applicatio n
      >
      Would become
      >
      Dim WordApp as Object
      Set WordApp = CreateObject("W ord.Application ")
      ----
      >
      This works with Word, as told, but you can give a try with Outlook.
      >
      If you have issues, let me know and I will give a try to make it work.
      >
      Regards,
      Branislav Mihaljev
      Microsoft Access MVP
      Oh, I forgot. To remove reference programmaticall y use:

      Application.Ref erences.Remove FileName

      I assume you can test to see if DLL file exists with:

      If Len(Dir(FileNam e)) 0 and then use Remove/AddFromFile commands.

      Regards,
      Branislav Mihaljev
      Microsoft Access MVP

      Comment

      • paii, Ron

        #4
        Re: Multiple Versions of Outlook


        "musiclover lch" <lhowey@gmail.c omwrote in message
        news:c26869b6-38b6-4414-bebe-d0134675b015@f4 0g2000pri.googl egroups.com...
        Hi all,
        >
        I have a database being used by 30 people and is split between the
        backend and frontend. The database has the ability to send e-mails
        through Outlook and I have even put Redemption on people's PCs as to
        not get all the Outlook security prompts. Here's the problem: Half
        are using Outlook 2003, the other half is using Outlook 2007, and 1 is
        using Outlook XP. I am using Outlook 2007, so my reference is set to
        use Microsoft Outlook 12.0, but other people need Outlook 11.0
        >
        Can I programmaticall y have the database detect what type of Outlook
        is on the PC and set the reference accordingly?
        >
        Thanks in advance,
        Laura
        Look at the difference between Early and Late Binding. You are using early
        binding which requires a reference to Outlook. the following function uses
        late binding to create and preview or send a email using Outlook. Preview
        does NOT cause the security warning. With late binding, you will need to
        declare any constants you wish to use.

        '---------------------
        ' Create a email with attachments
        ' stSendTo Email address
        ' stBody Body of the message
        ' stSubject Subject of the message
        ' astAttach Array of strings listing the path to the attachments
        ' intAcount Number of attachments
        ' intSend True if the message should be sent without preview

        Public Function EmailAttach(ByR ef stSendTo As String, ByRef stBody As
        String, ByRef stSubject As String, _
        astAttach() As String, intAcount As
        Integer, intSend As Integer) As Integer

        On Error GoTo errEmailAttach

        Dim oLook As Object
        Dim oMail As Object
        Dim i As Integer

        Set oLook = CreateObject("O utlook.Applicat ion")
        Set oMail = oLook.CreateIte m(0)
        With oMail
        .To = stSendTo
        .Body = stBody
        .Subject = stSubject
        .ReadReceiptReq uested = True

        If intAcount <0 Then
        For i = 1 To intAcount
        .Attachments.Ad d (astAttach(i - 1))
        Next
        End If

        If intSend = True Then
        .Send
        Else
        .Display
        End If

        End With

        Set oMail = Nothing
        Set oLook = Nothing
        EmailAttach = True
        Exit Function

        errEmailAttach:

        MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
        Chr$(13) & _
        "Your email may not have been sent.", vbCritical, "Error"

        On Error Resume Next
        Set oMail = Nothing
        Set oLook = Nothing
        EmailAttach = False

        End Function


        Comment

        • musicloverlch

          #5
          Re: Multiple Versions of Outlook

          Thanks for all your advice. I actually found something really cool on
          experts-exchange after I read all the (very boring) stuff about early
          vs late binding. This works great!:


          Dim theRef As Variant, i As Long
          Dim ref As Reference, strPath98 As String, strPath00 As String
          Dim strPathXP As String, strPath03 As String, strPath07 As String
          Dim fs
          Set fs = CreateObject("S cripting.FileSy stemObject")

          'Update the GUID you need below.
          strPath98 = "C:\Program Files\Microsoft Office\Office
          \msoutl85.olb"
          strPath00 = "C:\Program Files\Microsoft Office\Office\m soutl9.olb"
          strPathXP = "C:\Program Files\Microsoft Office
          \Office10\msout l.olb"
          strPath03 = "C:\Program Files\Microsoft Office
          \OFFICE11\msout l.olb"
          strPath07 = "C:\Program Files\Microsoft Office
          \OFFICE12\msout l.olb"

          'Set to continue in case of error
          On Error Resume Next

          'Remove any missing references
          For i = 1 To Application.Ref erences.Count
          Set theRef = Application.Ref erences.Item(i)
          If theRef.IsBroken = True Then
          Application.Ref erences.Remove (theRef)
          End If
          Next i

          'Clear any errors so that error trapping for GUID additions can
          be evaluated
          Err.Clear

          'Add the reference
          If fs.FileExists(s trPath07) Then
          Application.Ref erences.AddFrom File strPath07
          ElseIf fs.FileExists(s trPath98) Then
          Application.Ref erences.AddFrom File strPath98
          ElseIf fs.FileExists(s trPath03) Then
          Application.Ref erences.AddFrom File strPath03
          ElseIf fs.FileExists(s trPath00) Then
          Application.Ref erences.AddFrom File strPath00
          ElseIf fs.FileExists(s trPathXP) Then
          Application.Ref erences.AddFrom File strPathXP
          End If

          'If an error was encountered, inform the user
          Select Case Err.Number
          Case Is = 32813
          'Reference already in use. No action necessary
          Case Is = vbNullString
          'Reference added without issue
          Case Else
          'An unknown error was encountered, so alert the user
          MsgBox "A problem was encountered trying to" & vbNewLine _
          & "add or remove a reference in this file" & vbNewLine &
          "Please check the " _
          & "references in your VBA project!", vbCritical + vbOKOnly,
          "Error!"
          End Select
          On Error GoTo 0
          End Sub



          On Nov 20, 7:10 am, "paii, Ron" <n...@no.comwro te:
          "musiclover lch" <lho...@gmail.c omwrote in message
          >
          news:c26869b6-38b6-4414-bebe-d0134675b015@f4 0g2000pri.googl egroups.com...
          >
          Hi all,
          >
          I have a database being used by 30 people and is split between the
          backend and frontend.  The database has the ability to send e-mails
          through Outlook and I have even put Redemption on people's PCs as to
          not get all the Outlook security prompts.  Here's the problem: Half
          are using Outlook 2003, the other half is using Outlook 2007, and 1 is
          using Outlook XP.  I am using Outlook 2007, so my reference is set to
          use Microsoft Outlook 12.0, but other people need Outlook 11.0
          >
          Can I programmaticall y have the database detect what type of Outlook
          is on the PC and set the reference accordingly?
          >
          Thanks in advance,
          Laura
          >
          Look at the difference between Early and Late Binding. You are using early
          binding which requires a reference to Outlook. the following function uses
          late binding to create and preview or send a email using Outlook. Preview
          does NOT cause the security warning. With late binding, you will need to
          declare any constants you wish to use.
          >
          '---------------------
          ' Create a email with attachments
          '   stSendTo       Email address
          '   stBody         Body of the message
          '   stSubject      Subject of the message
          '   astAttach      Array of strings listing the path to the attachments
          '   intAcount      Number of attachments
          '   intSend        True if the message should be sent without preview
          >
          Public Function EmailAttach(ByR ef stSendTo As String, ByRef stBody As
          String, ByRef stSubject As String, _
                                           astAttach() As String, intAcount As
          Integer, intSend As Integer) As Integer
          >
              On Error GoTo errEmailAttach
          >
              Dim oLook As Object
              Dim oMail As Object
              Dim i As Integer
          >
              Set oLook = CreateObject("O utlook.Applicat ion")
              Set oMail = oLook.CreateIte m(0)
                  With oMail
                      .To = stSendTo
                      .Body = stBody
                      .Subject = stSubject
                      .ReadReceiptReq uested = True
          >
                      If intAcount <0 Then
                          For i = 1 To intAcount
                              .Attachments.Ad d (astAttach(i - 1))
                          Next
                      End If
          >
                      If intSend = True Then
                          .Send
                      Else
                          .Display
                      End If
          >
                  End With
          >
              Set oMail = Nothing
              Set oLook = Nothing
              EmailAttach = True
              Exit Function
          >
          errEmailAttach:
          >
              MsgBox "The following error was noted : " & Err.Description & Chr$(10) &
          Chr$(13) & _
                     "Your email may not have been sent.", vbCritical, "Error"
          >
              On Error Resume Next
              Set oMail = Nothing
              Set oLook = Nothing
              EmailAttach = False
          >
          End Function

          Comment

          Working...