ColdFusion Fax – Send a Binary File Using SendFax

This sample demonstrates how to send a binary fax from ColdFusion using the SendFax method.

The following ColdFusion fax snippet submits a binary file to the Web service, and indicates whether the submission succeeded. The return value of a successful submission is the transaction ID (positive number) of the fax in the system. Other return values indicate a failure (for more details, see Web Service Return Codes).


<!--- Username and password for the Interfax account. --->
<cfset interfaxUsername = "">
<cfset interfaxPassword = "">

      Fax number where the message is to be sent.
    For the format of the fax number please see:
<cfset faxNumber = "">
<cffile action="readbinary" file="#ExpandPath('.')#/sample.pdf" variable="fileData">
<cfset filetype = "PDF">

<!--- Create and call the web service --->
<cfset faxWebService = CreateObject("webservice", "")>

<cfset SendfaxResult = faxWebService.Sendfax(interfaxUsername, interfaxPassword, faxNumber, fileData, filetype)>

<!--- Check to see if the fax was sent ok. --->
<cfif SendfaxResult gt 0>
    Fax submitted ok. Transaction ID: #SendfaxResult#
    Error submitting fax.
    Return code: #SendfaxResult#.<br>
    Error message:  #SendfaxResult#