Windows 2000/XP offers two possibilities to send faxes programmatically, either by a COM-Object (faxcom.dll) or by an API (winfax.dll). The COM object also can be used in script languages like JScript, however, it isn't so flexible as the API. Through the API, on the other hand, you receive control over the sending process during sending. To be able to send faxes by a web page, I have written an ISAPI extension using the Fax-API.
To use the fax API, you must use the corresponding header files and libraries from the Microsoft Platform SDK. You can download the Platform SDK under http://msdn.microsoft.com/download free of charge.
Installation and Configuration
To be able to use the ISAPI-Extension, the IIS and Microsoft Fax service must, of course, be installed and working faultlessly. Before you use the ISAPI-Extension, you must test faxing by sending a document, e.g., over Wordpad to the fax printer.
After it, create a new web folder and out of it an application by using the IIS-Manager. The "execution rights" of the application must be set to "script and executable files ", the application protection to "low (IIS process)":
Through "Authentication methods", the anonymous access must be prevented:
After it, you copy the ISAPI-Extension (FaxISAPI.DLL) and the necessary ASP files (default.asp, progress.asp and ready.asp) into the web folder. Now start the browser and enter the address to the web folder (e.g., "http://localhost/fax") and send a fax through the web page.
The code of the FaxISAPI.DLL consists of three .cpp files. The file extension.cpp contains the functions for the ISAPI-Extension, upload.cpp contains the C++ class for the Upload, fax.cpp contains the C++ class for initializing the fax server and for sending faxes.
To inform the client about status information of the Upload and fax process, the ISAPI-DLL writes into a status file (this status file will be created in "c:\ winnt\temp" and the name of it corresponds to the Session ID + ".log").
The ASP file, progress.asp, is refreshed by the browser every second and the progress.asp reads the Status on the server from the status file.
Upload of the File to be Faxed
CUpload class contains the methods for the Upload of exactly one file to a web server. The class writes the number of bytes written to the status file and also the length of the file. This status information is used by progress.asp to show a progress bar. The uploaded file is stored intermediately in the folder "c:\winnt\temp".
Faxing the Uploaded File
CFax contains the methods for the Initializing/Deinitialising (
Init, DeInit) of the fax service and the method for sending Fax documents (
send). The method
Init of the ISAPI.DLL is called when loading the DLL the first time,
DeInit when unloading the DLL. The real sending process of the fax document is implemented in
CFax::Send. The ISAPI-DLL finishes its work and sends a Redirect to ready.asp to the browser after the fax was sent. Ready.asp then gives the user information about whether the fax could be successfully sent.
Through the fax API, you can access all essential events of the fax service.