[archive] Fax from ACUCOBOL-GT using Windows Fax services
[Migrated content. Thread originally posted on 30 June 2009]My colleague Claudio has created this nice little example on how to send fax from ACUCOBOL-GT using the Windows Fax Services.
Thought we should share it with you, as I seem to remember there were an inquiry for this some time ago.
To run this, you have to generate the fxcomdef.def using AxDefGen.exe.
You also need to provide the document to fax.
03 ERROR-INFO-RESULT USAGE UNSIGNED-INT.
03 ERROR-INFO-FACILITY USAGE UNSIGNED-SHORT.
03 ERROR-INFO-CODE USAGE UNSIGNED-SHORT.
01 ERROR-SOURCE PIC X(50).
01 ERROR-DESCRIPTION PIC X(200).
01 ERROR-HELP-FILE PIC X(50).
01 ERROR-HELP-CONTEXT USAGE UNSIGNED-LONG.
77 hdlFax HANDLE OF FaxServer.
77 hdlFaxDoc HANDLE OF FaxDocument.
77 JobID PIC S9(9) COMP-5.
77 ws-cover-path PIC x(50) VALUE
77 ws-doc-path PIC x(50) VALUE
* USE AFTER STANDARD EXCEPTION ON OBJECT.
USE AFTER EXCEPTION ON OBJECT.
CALL "C$EXCEPINFO" USING
IF ERROR-INFO-RESULT NOT = 2147614725
DISPLAY MESSAGE BOX "Uknown error"
| This is an error we have no explanation of, the
| fax goes just fine, so we just ignore this error.
* To have further info:
CREATE FaxServer OF FAXCOMEXLib
HANDLE IN hdlFax.
MODIFY hdlFax @connect = "".
CREATE FaxDocument OF FAXCOMEXLib
HANDLE IN hdlFaxDoc.
* Optionally, set the sender properties.
* MODIFY hdlFaxDoc @Sender::Name = "".
* MODIFY hdlFaxDoc @Sender::Email = "".
* MODIFY hdlFaxDoc @Sender::FaxNumber = "".
* Cover page's subject field
MODIFY hdlFaxDoc @Subject =
"Fax from ACUCOBOL-GT".
* Document's friendly name
MODIFY hdlFaxDoc @DocumentName =
"Test of Fax functionality".
* Add recipient's fax number. If this string contains a canonical fax number
* (starting with plus + followed by country code, area code in round brackets and the fax number),
* the Fax Service will translate that number into dialable format in accordance with your current location.
* Otherwise, make sure the international prefix or long distance prefix is specified when needed,
* as the fax number will be passed on to a fax driver (Fax Service Provider) unchanged.
* For example, sending a fax from San Francisco to Sydney's fax number 123456, the canonical address
* +61(2)123456 will be translated into dialable address 011612123456.
* If you are using T37FSP in conjunction with Internet Fax Service, specify absolute address
* 612123456 (without leading plus, to avoid translation into dialable format),
* as Internet Fax Service expects the number in the absolute format.
MODIFY hdlFaxDoc @Recipients::Add ("00523623155").
* The CoverPage property is a null-terminated string that contains the name
* of the cover page template file (.cov) to associate with the fax document.
* This .cov file has to be associated with an application that is installed on the computer,
* and the application has to support the PrintTo verb; otherwise, the fax will fail.
* To specify a server-based cover page file, you must set the FaxDocument.CoverPageType property to 2.
* To specify a local or personal cover page file, you must set the FaxDocument.CoverPageType property to 1.
* MODIFY hdlFaxDoc @CoverPageType = 1
* MODIFY hdlFaxDoc @CoverPage = ws-cover-path.
* The Note property is a null-terminated string that contains the contents
* of the note field on the cover page of the fax.
* MODIFY hdlFaxDoc @Note =
* "For the kind attention of Sales Office".
* The Body property provides the path to the file that comprises the body of a fax.
* The body of a fax consists of the fax pages other than the cover page.
* Examples of documents that you can send as a fax body are a text file (.txt),
* a Microsoft Word document (.doc), or a Microsoft Excel spreadsheet (.xls).
* When you send a fax from a client computer, the body has to be associated
* with an application that is installed on that computer, and the application
* has to support the PrintTo verb; otherwise, the fax will fail.
MODIFY hdlFaxDoc @BODY = ws-doc-path.
* Submit the document to the connected fax server and get back the job ID.
MODIFY hdlFaxDoc @ConnectedSubmit(hdlFax)