ColdFusion Fax – Send Plain-Text Message Using SendCharFax

The SendCharFax method allows you to send a basic, plain-text fax from ColdFusion. Text is limited to be standard ASCII (no 8-bit characters), but can include HTML markup.

Using HTML causes automatic word wrapping, whereas regular text does not.

This ColdFusion fax sample submits a plain-text 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: https://www.interfax.net/en/dev/webservice/reference.html#appendixb
--->
<cfset faxNumber = "">

<!--- The plain text content of the fax goes here --->
<cfsavecontent variable="faxMessage">
Your fax content goes here.
</cfsavecontent>


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

<cfset faxID = faxWebService.SendCharFax(interfaxUsername, interfaxPassword, faxNumber, faxMessage, "TXT")>


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