ColdFusion Fax – Get List of Inbound Faxes

The GetList method demonstrated in this sample allows you to retrieve a list of inbound (received) faxes with ColdFusion.

In the ColdFusion fax snippet below, the GetList method is used to display information for a number of submitted faxes:


<cfoutput>

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

<cfset objMessageItem = ArrayNew(1)>
<cfset listType       = "AllMessages">
<cfset maxItems    = 10>


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

<cfset resultCode = faxWebservice.getList(interfaxUsername, interfaxPassword, listType, maxItems, "objMessageItem")>


<!--- If the result code is 0 then the call was succesfull --->
<cfif resultCode eq 0>

    <!--- If the objMessageItems doen't exist then we don't have any faxes on the server --->
    <cfif isDefined("objMessageItem")>

        <!--- Get all the faxes --->
        <cfset faxItems = objMessageItem.getMessageItem()>

        <!--- Display the info for the retrieved faxes --->
        <table border="2">
        <tr>
            <th>MessageID</th>
            <th>PhoneNumber</th>
            <th>RemoteCSID</th>
            <th>MessageStatus</th>
            <th>Pages</th>
            <th>MessageSize</th>
            <th>MessageType</th>
            <th>ReceiveTime</th>
            <th>MessageRecordingDuration</th>
        </tr>
        <cfloop from="1" to="#ArrayLen( faxItems )#" index="i">
            <cfset currentFaxItem = faxItems[i]>
            <tr>
                <td>#currentFaxItem.getMessageID()#</td>
                <td>#currentFaxItem.getPhoneNumber()#</td>
                <td>#currentFaxItem.getRemoteCSID()#</td>
                <td>#currentFaxItem.getMessageStatus()#</td>
                <td>#currentFaxItem.getPages()#</td>
                <td>#currentFaxItem.getMessageSize()#</td>
                <td>#currentFaxItem.getMessageType()#</td>
                <td>#currentFaxItem.getReceiveTime()#</td>
                <td>#currentFaxItem.getMessageRecordingDuration()#</td>
            </tr>
        </cfloop>
        </table>

    <cfelse>

        No faxes to retrieve.

    </cfif>

<cfelse>

    Error message: #resultCode#

</cfif>
</cfoutput>