Skip to main content

Interfacing with Outlook

  • May 16, 2021
  • 3 replies
  • 0 views

Hi all, 

I have some components written several years ago with which you can create emails by interfacing Outlook.
When I developed the components, the Microsoft library available for Office 2010 was version 14.
Of course Office has changed in the meantime and now the available library is version 16.
It is not a problem to change the Outlook signatures in Uniface to use the new library but a problem exists when old and new versions of Office coexist within the same company installation.
It is not a big problem to insert in the forms that interface with Outlook some controls linked in some way to each individual user to check which library is available in his workstation but, if possible, I would like to avoid it.
In VBA these things can be solved with the Late Binding technique with which you work with Objects to create application instances (Excel, Outlook and so on).
The standard Early Binding technique is exactly the one that is currently available with Uniface with which Outlook instances are created through the interfacing allowed by its signatures that have been previously imported.
Are there alternatives that allow you to avoid 'worrying' about the version of Office present in the workstation?

If it may be useful to report one of the many examples in VBA found on the Internet of the two techniques I have described:

============================================================

Early Binding ------------------------

'~~> Set reference to Excel Object Library Sub Sample() Dim oXLApp As Excel.Application Dim oXLBook As Excel.Workbook Dim oXLSheet As Excel.Worksheet '~~> Create a new instance of Excel Set oXLApp = New Excel.Application '~~> Add a new workbook Set oXLBook = oXLApp.Workbooks.Add Set oXLSheet = oXLBook.Worksheets(1) ' '~~> Rest of the code ' End Sub
============================================================

Late Binding ----------------------
'~~> Doesn't require a reference to Excel Object Library
Sub Sample()
    Dim oXLApp As Object
    Dim oXLBook As Object
    Dim oXLSheet As Object

    '~~> Create a new instance of Excel
    Set oXLApp = CreateObject("Excel.Application")
    '~~> Add a new workbook
    Set oXLBook = oXLApp.Workbooks.Add
    Set oXLSheet = oXLBook.Worksheets(1)
    '
    '~~> Rest of the code
    '
End Sub
============================================================

Many thanks
Luigi

3 replies

Gianni Sandigliano
Forum|alt.badge.img

Hi all, 

I have some components written several years ago with which you can create emails by interfacing Outlook.
When I developed the components, the Microsoft library available for Office 2010 was version 14.
Of course Office has changed in the meantime and now the available library is version 16.
It is not a problem to change the Outlook signatures in Uniface to use the new library but a problem exists when old and new versions of Office coexist within the same company installation.
It is not a big problem to insert in the forms that interface with Outlook some controls linked in some way to each individual user to check which library is available in his workstation but, if possible, I would like to avoid it.
In VBA these things can be solved with the Late Binding technique with which you work with Objects to create application instances (Excel, Outlook and so on).
The standard Early Binding technique is exactly the one that is currently available with Uniface with which Outlook instances are created through the interfacing allowed by its signatures that have been previously imported.
Are there alternatives that allow you to avoid 'worrying' about the version of Office present in the workstation?

If it may be useful to report one of the many examples in VBA found on the Internet of the two techniques I have described:

============================================================

Early Binding ------------------------

'~~> Set reference to Excel Object Library Sub Sample() Dim oXLApp As Excel.Application Dim oXLBook As Excel.Workbook Dim oXLSheet As Excel.Worksheet '~~> Create a new instance of Excel Set oXLApp = New Excel.Application '~~> Add a new workbook Set oXLBook = oXLApp.Workbooks.Add Set oXLSheet = oXLBook.Worksheets(1) ' '~~> Rest of the code ' End Sub
============================================================

Late Binding ----------------------
'~~> Doesn't require a reference to Excel Object Library
Sub Sample()
    Dim oXLApp As Object
    Dim oXLBook As Object
    Dim oXLSheet As Object

    '~~> Create a new instance of Excel
    Set oXLApp = CreateObject("Excel.Application")
    '~~> Add a new workbook
    Set oXLBook = oXLApp.Workbooks.Add
    Set oXLSheet = oXLBook.Worksheets(1)
    '
    '~~> Rest of the code
    '
End Sub
============================================================

Many thanks
Luigi

Ciao Luigi,

Nice question!

I try to give you my answer:

Up to U10 Uniface was and is "Component based"; a component is an implementation of an object.
The Uniface product itself is internally reusing many OO tecniques but it is NOT an "Object based" development environment.

For this reason declaring a generic "Object", like in your "Late Binding" example, it is IMHO something not really in line with Uniface product.
For the time being it should be preferrable to have an intermediate layer to accomplish with various versions of same product; using /sti you could define a prefix, so you could import and save different versions of the same signature, Excel in your case, like:
- E8_WORKBOOKS(params)
- E16_WORKBOOKS(params)
and the intermediate layer should be able to switch between them:
if (E16)
    activate E16_WORKBOOKS(params)
else
    activate E8_WORKBOOKS(params)
endif

It could be Uniface in a (next) future will start to release more (and more) OO support; Product Management could detail about it.

Hope it helps.

Regards,
Gianni

BTW: I am interested to other opinions too! 🙂


Gianni Sandigliano
Forum|alt.badge.img

Hi all, 

I have some components written several years ago with which you can create emails by interfacing Outlook.
When I developed the components, the Microsoft library available for Office 2010 was version 14.
Of course Office has changed in the meantime and now the available library is version 16.
It is not a problem to change the Outlook signatures in Uniface to use the new library but a problem exists when old and new versions of Office coexist within the same company installation.
It is not a big problem to insert in the forms that interface with Outlook some controls linked in some way to each individual user to check which library is available in his workstation but, if possible, I would like to avoid it.
In VBA these things can be solved with the Late Binding technique with which you work with Objects to create application instances (Excel, Outlook and so on).
The standard Early Binding technique is exactly the one that is currently available with Uniface with which Outlook instances are created through the interfacing allowed by its signatures that have been previously imported.
Are there alternatives that allow you to avoid 'worrying' about the version of Office present in the workstation?

If it may be useful to report one of the many examples in VBA found on the Internet of the two techniques I have described:

============================================================

Early Binding ------------------------

'~~> Set reference to Excel Object Library Sub Sample() Dim oXLApp As Excel.Application Dim oXLBook As Excel.Workbook Dim oXLSheet As Excel.Worksheet '~~> Create a new instance of Excel Set oXLApp = New Excel.Application '~~> Add a new workbook Set oXLBook = oXLApp.Workbooks.Add Set oXLSheet = oXLBook.Worksheets(1) ' '~~> Rest of the code ' End Sub
============================================================

Late Binding ----------------------
'~~> Doesn't require a reference to Excel Object Library
Sub Sample()
    Dim oXLApp As Object
    Dim oXLBook As Object
    Dim oXLSheet As Object

    '~~> Create a new instance of Excel
    Set oXLApp = CreateObject("Excel.Application")
    '~~> Add a new workbook
    Set oXLBook = oXLApp.Workbooks.Add
    Set oXLSheet = oXLBook.Worksheets(1)
    '
    '~~> Rest of the code
    '
End Sub
============================================================

Many thanks
Luigi

Hi all,

while doing a small chat on the phone about this issue we found the used Outlook signature was referring to a specific Outlook version into its COM properties: ProgID was defined as "Outlook.Application.XX" with its related ClsID. This was obviously limiting its use to the specific Outlook version defined.

We tried to change it to the generic reference: "Outlook.Application", and its related ClsID was obviously updated.

Luigi is now verifying if it works correctly with all Outlook versions installed onPremises up to the current one; he will keep us updated soon with his verification results.

Regards,
Gianni


  • Author
  • Participating Frequently
  • May 18, 2021

Hi all, 

I have some components written several years ago with which you can create emails by interfacing Outlook.
When I developed the components, the Microsoft library available for Office 2010 was version 14.
Of course Office has changed in the meantime and now the available library is version 16.
It is not a problem to change the Outlook signatures in Uniface to use the new library but a problem exists when old and new versions of Office coexist within the same company installation.
It is not a big problem to insert in the forms that interface with Outlook some controls linked in some way to each individual user to check which library is available in his workstation but, if possible, I would like to avoid it.
In VBA these things can be solved with the Late Binding technique with which you work with Objects to create application instances (Excel, Outlook and so on).
The standard Early Binding technique is exactly the one that is currently available with Uniface with which Outlook instances are created through the interfacing allowed by its signatures that have been previously imported.
Are there alternatives that allow you to avoid 'worrying' about the version of Office present in the workstation?

If it may be useful to report one of the many examples in VBA found on the Internet of the two techniques I have described:

============================================================

Early Binding ------------------------

'~~> Set reference to Excel Object Library Sub Sample() Dim oXLApp As Excel.Application Dim oXLBook As Excel.Workbook Dim oXLSheet As Excel.Worksheet '~~> Create a new instance of Excel Set oXLApp = New Excel.Application '~~> Add a new workbook Set oXLBook = oXLApp.Workbooks.Add Set oXLSheet = oXLBook.Worksheets(1) ' '~~> Rest of the code ' End Sub
============================================================

Late Binding ----------------------
'~~> Doesn't require a reference to Excel Object Library
Sub Sample()
    Dim oXLApp As Object
    Dim oXLBook As Object
    Dim oXLSheet As Object

    '~~> Create a new instance of Excel
    Set oXLApp = CreateObject("Excel.Application")
    '~~> Add a new workbook
    Set oXLBook = oXLApp.Workbooks.Add
    Set oXLSheet = oXLBook.Worksheets(1)
    '
    '~~> Rest of the code
    '
End Sub
============================================================

Many thanks
Luigi

I have repeated the tests in the client installation with complete success.
This shows that even in computer science the concept of Occam's razor sometimes holds.


My thanks to Gianni for his precious help.