Click here to Skip to main content
15,883,949 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 241K   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

 
Generalerror Pin
Member 7436803-Dec-03 1:04
Member 7436803-Dec-03 1:04 
GeneralDoesn't create the sessionid.log file in winnt\temp folder Pin
Member 56545124-Sep-03 0:59
Member 56545124-Sep-03 0:59 
GeneralRe: Doesn't create the sessionid.log file in winnt\temp folder Pin
Sönke Cordts24-Sep-03 1:02
Sönke Cordts24-Sep-03 1:02 
Generaljava fax Pin
nowmedia22-Jul-03 0:21
nowmedia22-Jul-03 0:21 
GeneralRe: java fax Pin
liuxiao121724-Nov-03 18:22
liuxiao121724-Nov-03 18:22 
GeneralISAPI in C# Pin
Arash Sabet21-Jul-03 5:41
Arash Sabet21-Jul-03 5:41 
GeneralSolutions Pin
Anonymous14-Jun-03 0:25
Anonymous14-Jun-03 0:25 
Generalcan't build the dll Pin
Member 43293311-Jun-03 0:38
Member 43293311-Jun-03 0:38 
when I build the dll, it shows errors like this:winfax.h(672) : error C2146: syntax error : missing ';' before identifier 'Reserved'
GeneralRe: can't build the dll Pin
E L N I N O6-Apr-04 1:17
E L N I N O6-Apr-04 1:17 
GeneralRe: can't build the dll Pin
nsmalwankar29-Oct-04 9:21
nsmalwankar29-Oct-04 9:21 
GeneralError Pin
Ciel.Zanato8-Jun-03 1:53
Ciel.Zanato8-Jun-03 1:53 
GeneralHelp needed Pin
Qayyum Asma20-May-03 17:59
Qayyum Asma20-May-03 17:59 
QuestionWorked examples? Pin
Butter0822-Jan-03 4:40
Butter0822-Jan-03 4:40 
GeneralFaxSendDocument and HTML format Pin
Mukesh27-Nov-02 19:38
Mukesh27-Nov-02 19:38 
GeneralRe: FaxSendDocument and HTML format Pin
LukCastles17-Dec-02 2:28
LukCastles17-Dec-02 2:28 
Generalwhy,help me Pin
ansonding23-Oct-02 23:45
ansonding23-Oct-02 23:45 
GeneralRe: why,help me Pin
aspprog27-Dec-02 17:15
aspprog27-Dec-02 17:15 
Generalplease help me Pin
kokuma23-Oct-02 16:36
kokuma23-Oct-02 16:36 
GeneralInternal Server Error Pin
Kendo6523-Oct-02 14:20
sussKendo6523-Oct-02 14:20 
GeneralRe: Internal Server Error Pin
Erkang Zheng4-Dec-03 8:08
Erkang Zheng4-Dec-03 8:08 
GeneralRe: Internal Server Error Pin
anthonyar6-Dec-03 11:53
anthonyar6-Dec-03 11:53 
GeneralRe: Internal Server Error Pin
Wualla7-May-04 2:23
Wualla7-May-04 2:23 
GeneralRe: Internal Server Error Pin
fabfoot27-Apr-06 3:47
fabfoot27-Apr-06 3:47 
GeneralWinFax lib/.h file Pin
Anonymous10-Oct-02 1:11
Anonymous10-Oct-02 1:11 
GeneralRe: WinFax lib/.h file Pin
Sönke Cordts10-Oct-02 2:00
Sönke Cordts10-Oct-02 2:00 

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.