Click here to Skip to main content
15,867,756 members
Articles / Desktop Programming / MFC

ISAPI Extension for Sending Faxes

Rate me:
Please Sign up or sign in to vote.
3.23/5 (13 votes)
26 Mar 2002CPOL3 min read 240.3K   3.2K   53   62
An article on sending faxes through a Web page

Introduction

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.

Implementation

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.

The default.asp contains the HTML form to get the fax number from the user. The fax number then is passed to choosefile.asp. The file choosefile.asp contains the HTML form for the choice of the faxing file and calls the FaxISAPI.DLL at a "Submit" and opens simultaneously a new browser window by JavaScript with the progress.asp.

Upload of the File to be Faxed

The 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.

Conclusion

Through the fax API, you can access all essential events of the fax service.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
behzad200015-Oct-13 20:20
behzad200015-Oct-13 20:20 
Questionthe web not run. only refresh Pin
hoacksl28-Apr-12 22:52
hoacksl28-Apr-12 22:52 
Questionwhat am I missing? Pin
zepp24-May-06 17:35
zepp24-May-06 17:35 
GeneralWorks fine just one time Pin
Eric-7722-May-06 1:01
Eric-7722-May-06 1:01 
GeneralCan't get it to work. Pin
supz22-May-06 0:00
supz22-May-06 0:00 
GeneralRe: Can't get it to work. Pin
supz22-May-06 1:03
supz22-May-06 1:03 
Sorry my fault. Forgot some setting. But now I get the Page Cannot be displayed immediately. And in the FaxISAPI.log there's the following error

"Sending document..."
"Error: The wait operation timed out.
(0x102, 23)"
"Bye from faxserver"

Any ideas???
GeneralRe: Can't get it to work. Pin
supz8-Jan-07 19:34
supz8-Jan-07 19:34 
Generalpossible error in CUploadFile Pin
bartm10-May-06 0:48
bartm10-May-06 0:48 
GeneralErreur Interne Pin
fabfoot27-Apr-06 4:12
fabfoot27-Apr-06 4:12 
GeneralIT SIMPLY DOESN'T WORK! Pin
fatehh14-Jul-05 2:56
fatehh14-Jul-05 2:56 
GeneralRe: IT SIMPLY DOESN'T WORK! Pin
Mohit Raj31-Jul-05 18:24
Mohit Raj31-Jul-05 18:24 
GeneralAbout fax project Pin
krish2k59-Apr-05 0:02
krish2k59-Apr-05 0:02 
GeneralRe: About fax project Pin
Mohit Raj31-Jul-05 18:16
Mohit Raj31-Jul-05 18:16 
GeneralSending Multiple Fax (2) Pin
alberto_mecho26-Nov-04 5:26
alberto_mecho26-Nov-04 5:26 
GeneralSending multiple fax Pin
alberto_mecho26-Nov-04 1:49
alberto_mecho26-Nov-04 1:49 
GeneralRectification note Pin
alberto_mecho26-Nov-04 3:29
alberto_mecho26-Nov-04 3:29 
Questionpre-requisites? Pin
nsmalwankar20-Oct-04 11:14
nsmalwankar20-Oct-04 11:14 
AnswerRe: pre-requisites? Pin
Mohit Raj31-Jul-05 18:19
Mohit Raj31-Jul-05 18:19 
Generalerror in sending fax Pin
hi_hemant141-Jun-04 3:02
hi_hemant141-Jun-04 3:02 
GeneralFaxes are "too light" Pin
Neil Katalino21-Apr-04 2:32
Neil Katalino21-Apr-04 2:32 
GeneralCan't Run Pin
garfieldlau13-Apr-04 20:30
garfieldlau13-Apr-04 20:30 
GeneralRe: Can't Run Pin
Mohit Raj30-Sep-04 18:44
Mohit Raj30-Sep-04 18:44 
GeneralRe: Can't Run Pin
nsmalwankar20-Oct-04 10:12
nsmalwankar20-Oct-04 10:12 
QuestionHow dees this DLL handle a multi-user enviroment? Pin
Member 89956822-Feb-04 18:57
Member 89956822-Feb-04 18:57 
Generalerror Pin
Member 7436803-Dec-03 1:04
Member 7436803-Dec-03 1:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.