.






Using OLE Servers in Visual Basic 4.0



Introduction

If I didn't know better (and I don't), I'd swear that OLE Servers were developed with VB4 in mind. There are no problems, so we'll just present the basics here.

Discussion

Coding to use OLE Servers from VB4 is very similar to using an ActiveX control. OLE Servers have properties and methods just like ActiveX's. The only real difference is how you include an OLE Server in your project.

When you add an ActiveX control (or VBX control) to your project, you select the Tools, Custom Controls menu selection and choose the control from the dialog. For an OLE Server, you do the same thing except you must select the Tools, References menu selection instead.

Now that you have a reference to the OLE Server, you can create an object from it with a single line of code:
    Dim idsMail As New IDSMailInterface.Server


In this case, we're using a server called IDSMail that provides universal Email send/receive capabilities. The programmatic ID for the server is "IDSMailInterface.Server". Excel, Word, Visio, etc. each have their own unique programmatic id's.

Now that you've done that, you can access the OLE Server just like an ActiveX:

    idsMail.ObjectKey = "ABCDE12345"  
    idsMail.AddRecipientTo "Jim Stevens"
    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


Looks familiar, right?

Resources

  • Download the complete source code for a VB 4.0 Universal Email Client (9k) that utilizes the IDSMail OLE Server. The client is compatible with both the 16-bit version and the 32-bit version of VB4.



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