Programming Mail- and Fax Solutions

ClassiX® does not support mail or fax reports by itself. To be able to send fax or email in ClassiX®, it is necessary to integrate external applications. This gets done via OLE automation which controls these integrated applications. In the following, Outlook will be used as an email and fax client. Lotus Notes and equivalent applications however, can be integrated in a similar manner.   

Outlook provides a comprehensive object model for programming (similar to MAPI – Mail Application Programming Interface), which does not depend on whether Outlook works as an autonomous mail program or whether it is connected to an exchange server. For further information see [1] or [2].

Sending an EMail

The following steps are required to programmatically send an email in Outlook:

  1. Provide Outlook Application Object
  2. Logging on
  3. Generate Mail
  4. Set Receiver
  5. Set Subject, Body and eventually attachment
  6. Viewing  (preview)
  7. Sending
  8. Logging off

1. Provide Outlook Application Object
The application object provides methods to control the application. In this case, it will be method to navigate through the Outlook folders, to generate new mails or contacts or even to modify the Outlook interface. 

    Var(olApp)
    CreateTransObject(CX_COM_OBJECT) -> olApp 
    "Outlook.Application" olApp Call(CreateFromProgID) 

This creates an object type Outlook.Application. The method CreateFromProgID cannot be found in the Outlook help, since it is a ClassiX® method from the class CX_COM_OBJECT.

2. Logging on
MAPI requires, that any user or program, who or which wants to do something needs to log on first to start a session. This is done via MAPI name space:

    Var(olSession)
    "MAPI" olApp Call(GetNamespace) -> olSession
    olSession Call(Logon)

The log on command also accepts parameters for (interactive) profile selection and a password. The default profile is used in the version shown above.

3. Generate Mail
Each element -no matter if mail, contact or note- gets generated with the application object method CreateItem. Parameter will be the according type as an integer. The type olMailItem (0) generates a mail:

    Var(olMail) 0 olApp Call(CreateItem) -> olMail

The object is an Outlook.MailItem.

4. Set Receiver
First, the receiver will be converted into a string, meaning receiver email or name will be set. Now it is possible to check, whether the receiver, or all receivers are valid according to Outlook. For SMPT addresses (xyz@abc.de), this is always the case unless the internet mailing service has not been installed. Whenever a name gets specified, Outlook checks whether there is an equivalent contact/address book entry and whether a valid mail address has been assigned.

    Var(olRecipients) olMail Call(GetRecipients) -> olRecipients
    "info@classix.de" olRecipients Call(Add) Drop
    "Egon Hubert" olRecipients Call(Add) Drop
    olRecipients Call(ResolveAll) ifnot {... Error handling ...}

5. Set Subject, Body and eventually Attachment
Mail subject and body are set as simple strings, and can be read that way, too. In case the mail is supposed to be sent in HTML format, it is possible to use HTML body instead of body.

    "any subject" olMail Call(PutSubject)
    "any subject" olMail Call(PutBody)

Attachments are made as file names:

    "c:\\anywhere\\anything.doc" olMail Call(GetAttachments) Call(Add)

6. Viewing (Preview)
The following method can be called to bring connected applications (Outlook, Notes, etc.) to the front:

    olMail Call(Display)

7. Sending
Just call the mail item method send:

    olMail Call(Send)

A sent email will generally not be confirmed. To receive a confirmation, it would be necessary to write a Plugin in Outlook or for exchange, which generates a message for ClassiX®, every time an email has been sent.

8. Logging off
The name space provides a method to log off. Although nothing would happen when not logging off, it is still recommended for a clean development:

    olSession Call(Logoff)

Sending a Fax

Sending a fax with ClassiX® also requires an OLE automation capable fax application. Other than the simple printer drivers, which allow access to a modem, an ISDN card or a central fax server to send a fax, there are also exchange and Outlook, providing very elegant solutions.

Outlook and exchange generally support different transfer - and addressing reports. Next to the SMPT/<Name@domain>, which is common on the internet, X.400/X.500 are also being supported. This simply requires the correct service provider to be installed (for an exchange installation just on the exchange server, otherwise in every Outlook installation).

With the passed addresses, the service provider tries to find the matching receiver (contact or address book entry) and submits the message  to one of the addresses saved in the receiver via installed transmission protocols. Here, receiver address and matching protocol are preferred. In case the receiver has not been saved, the passed address will be checked for possible protocols (e.g. if an @ is included, it is supposingly SMTP). In case a specific protocol shall be used, it can be specified in the form [protocol:address] as the receiver address (e.g. [smpt:christian.langmann@classix.de]. This notifies exchange/Outlook, that the address belongs to a specific protocol to send the message.

For faxing, it is necessary to install a fax provider on the exchange server or under Outlook (e.g. GFI FaxMaker). The protocol specification does not depend on the product, is often called "fax" or named after the producer, e.g. "faxmaker". A complete fax address could look as follows:"[fax:04020940150]".

Sending a fax means simply sending an email (fromClassiX®) to such an address. The sender program converts the content into the correct image format (a fax is always transmitted as an image), including attachments. Attachments need to be available in a printable format, meaning the attachments must be opened and printed by the converter. If for example an Acrobat PDF file gets sent as an attachment and the fax provider runs on an exchange server, Acrobat reader needs to be installed on this exchange server. Information on how to print this PDF file are in the registry. Depending on the according fax provider, these entries need to be adjusted.