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


<cfoutput>

<!--- 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: http://www.interfax.net/en/dev/webservice/reference.html#appendixb
--->
<cfset faxNumber = "">
<cffile action="readbinary" file="#ExpandPath('.')#/sample.pdf" variable="fileData">
<cfset filetype = "PDF">


<!--- Create and call the web service --->
<cfset faxWebService = CreateObject("webservice", "https://ws.interfax.net/dfs.asmx?WSDL")>

<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#
<cfelse>
    Error submitting fax.
    Return code: #SendfaxResult#.<br>
    Error message:  #SendfaxResult#
</cfif>
</cfoutput>

Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today