.






Using OLE Servers in Delphi 2.0



Introduction

When Borland released Delphi 2.0, they addressed one of the long-standing complaints about v1.0: the inability to use OLE Servers. And address it they did! The OLE Server interface in Delphi 2.0 is intuitive and robust.

NOTE: OLE Servers can be used in Delphi 1.0 with this workaround.

Overview

In Delphi 2.0, variant variables are used to reference OLE Servers. So, let's create one in the following code fragment:

    public
      idsMail: Variant;


Now we can create an instance of the server. In this example we'll use the IDSMail OLE Server which provides a universal Email send/receive programming interface:

    idsMail := CreateOLEObject('IDSMailInterface.Server');


In this code, IDSMailInterface.Server is the programmatic ID for the server. Excel, Word, Visio, etc. each have their own unique programmatic id's.

Now that we have an instance of the server, we can go ahead and compose and send an Email message using the IDSMail properties and methods:

    idsMail.ObjectKey := 'ABC123';
    idsMail.AddRecipientTo ('Jim Smith');
    idsMail.AddRecipientCc ('Mary Brown, Doug Williams');
    idsMail.Subject := 'Meeting Agenda';
    idsMail.AddAttachment ('C:\MEETINGS\AGENDA.DOC');
    idsMail.Message = 'Here is the agenda for this weeks meeting.';
    idsMail.Send;


Simple, huh? Other OLE Servers can be utilized with similar techniques.

Resources


© 1993-2004, AssurX, Inc. All Rights Reserved. Trademarks. 408-778-1376 | email: info@intuitive-data.com