Microsoft KB Archive/303647

= How To Send a Fax from an ASP Page on Windows 2000 =

Article ID: 303647

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Active Server Pages 3.0, when used with:
 * Microsoft Windows 2000 Standard Edition

-



This article was previously published under Q303647



SUMMARY
This article describes how to use Microsoft Fax Service to send a fax from an Active Server Pages (ASP) page. The Microsoft Fax Service includes Component Object Model (COM) interfaces that expose functionality that is contained in the Faxcom.dll file. By making calls to Faxcom.dll, you can instantiate the necessary object to send a fax from any client program that supports COM.

For more information about the FaxServer objects and their functionality, see the &quot;References&quot; section.

IMPORTANT: You cannot fax all file types from ASP and or a service. This article demonstrates how to fax a text document; further configuration or a different method may be necessary to fax documents of a different type.



Step-by-Step Example
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

To call the functionality that is contained in the FaxServer objects from ASP, follow these steps:  Open Microsoft Visual Basic. From the New Project dialog box, click ActiveX DLL, and then click Open. Rename the Visual Basic project FaxComWrapper . Rename the default Class1 module FaxSend .  Add the following code: Public Function SendFax(FileName As Variant, FaxMachine As Variant, FaxNumber As Variant) Set FaxServer = CreateObject(&quot;FaxServer.FaxServer&quot;) FaxServer.Connect (&quot;\\&quot; & FaxMachine) Set FaxDoc = FaxServer.CreateDocument(FileName) With FaxDoc .FaxNumber = FaxNumber .Send End With Set FaxDoc = Nothing Set FaxServer = Nothing End Function  Save the project to the C:\ASPFax\ folder. Compile the FaxComWrapper project to the C:\ASPFax\ folder, and name it FaxComWrapper.dll.</li> From the Start menu, point to Programs, point to Administrative Tools, and then click Component Services to open the Microsoft Management Console for Component Services (which is referred to as the console for the remainder of this article).</li> In the left pane of the console, click to expand the Component Services, Computers, My Computer, and COM+ Applications nodes.</li> Click to select COM+ Applications. From the Action menu, point to New, and then click Application. Follow these steps in the COM Application Install Wizard: <ol style="list-style-type: lower-alpha;"> On the first page of the wizard, click Next.</li> On the second page of the wizard, click Create an Empty Application, type FaxSendWrapper as the name of the application, and then click Next.</li> On the Set Application Identity page, click This User, and type the Administrator account and password credentials. This ensures that the application has the required permissions; however, you can modify this entry for a specific security configuration.</li> Click Next, and then click Finish.</li></ol> </li> Notice that the newly created application, FaxSendWrapper, appears in the list of COM+ applications on your computer. In the left pane, click to expand FaxSendWrapper, and then click to select Components. From the Action menu, point to New, and then click Component. Follow these steps in the COM Component Install Wizard: <ol style="list-style-type: lower-alpha;"> In the first page of the wizard, click Next.</li> In the second page of the wizard, click Import component(s) that are already registered.</li> In the list that is generated, click FaxComWrapper.FaxSend.</li> Click Next, and then click Finish.</li></ol> </li> Open Microsoft Visual InterDev, and create a new project. Add a new blank ASP page.</li>  Add the following code to the ASP page: <%

Set FaxWrapper = Server.CreateObject(&quot;FaxComWrapper.FaxSend&quot;)

Dim strFileName Dim strFaxMachine Dim strFaxNumber

strFileName = &quot;<Insert Filename Here>&quot; strFaxMachine = &quot;<Insert FaxMachine Here>&quot; strFaxNumber = &quot;<Insert FaxNumber Here>&quot; FaxWrapper.SendFax strFileName, strFaxMachine, strFaxNumber

Set FaxWrapper = Nothing

%>                   </li> Run the ASP page.</li></ol>

NOTE: The code for the Visual Basic dynamic-link library (DLL) that is included in this article is intended as a sample demonstration only. This code still requires error handling and must be tested thoroughly if you want to incorporate this concept in production code.

<div class="references_section">