How To Send a Fax from an ASP Page on Windows 2000 (303647)



The information in this article applies to:

  • Microsoft Active Server Pages 3.0, when used with:
    • the operating system: Microsoft Windows 2000

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 "References" 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.

MORE INFORMATION

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: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: To call the functionality that is contained in the FaxServer objects from ASP, follow these steps:
  1. Open Microsoft Visual Basic.
  2. From the New Project dialog box, click ActiveX DLL, and then click Open.
  3. Rename the Visual Basic project FaxComWrapper.
  4. Rename the default Class1 module FaxSend.
  5. Add the following code:
    Public Function SendFax(FileName As Variant, FaxMachine As Variant, FaxNumber As Variant)
       
        Set FaxServer = CreateObject("FaxServer.FaxServer")
        FaxServer.Connect ("\\" & FaxMachine)
        Set FaxDoc = FaxServer.CreateDocument(FileName)
        With FaxDoc
            .FaxNumber = FaxNumber
            .Send
        End With
          
        
        Set FaxDoc = Nothing
        Set FaxServer = Nothing
        
    End Function
    					
  6. Save the project to the C:\ASPFax\ folder.
  7. Compile the FaxComWrapper project to the C:\ASPFax\ folder, and name it FaxComWrapper.dll.
  8. 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).
  9. In the left pane of the console, click to expand the Component Services, Computers, My Computer, and COM+ Applications nodes.
  10. 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:
    1. On the first page of the wizard, click Next.
    2. On the second page of the wizard, click Create an Empty Application, type FaxSendWrapper as the name of the application, and then click Next.
    3. 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.
    4. Click Next, and then click Finish.
  11. 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:
    1. In the first page of the wizard, click Next.
    2. In the second page of the wizard, click Import component(s) that are already registered.
    3. In the list that is generated, click FaxComWrapper.FaxSend.
    4. Click Next, and then click Finish.
  12. Open Microsoft Visual InterDev, and create a new project. Add a new blank ASP page.
  13. Add the following code to the ASP page:
    <%
    
    Set FaxWrapper = Server.CreateObject("FaxComWrapper.FaxSend")
    
    Dim strFileName
    Dim strFaxMachine
    Dim strFaxNumber
    
    strFileName = "<Insert Filename Here>" 
    strFaxMachine = "<Insert FaxMachine Here>" 
    strFaxNumber = "<Insert FaxNumber Here>" 
     
    FaxWrapper.SendFax strFileName, strFaxMachine, strFaxNumber
    
    Set FaxWrapper = Nothing
    
    %>
    					
  14. Run the ASP page.
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.

REFERENCES

For more information on the Fax Service Client application programming interface (API), refer to the following MSDN Web site: For more information on COM+ development for Visual Basic, refer to the following MSDN Web site:

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbASPObj kbCodeSnippet kbhowto kbSample kbScript KB303647