C# Fax – Cancel a Submitted Fax

Download the C# fax API zip file.

This code sample uses the CancelFax method to cancel a previously-submitted (outbound) C# fax. Using CancelFax only effects faxes waiting to be sent (with the status codes: -1 Preprocessing, -2 Ready, or -3 Pending Retry), and not faxes that are being actively transmitted.

In the C# fax code snippet below, an inbound fax is cancelled, and a check is performed to see if the cancellation succeeded:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CancelFax
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = "";
            string password = "";
            int transactionID = 546585833;
            interfax.InterFax interfaxWebServiceOutbound = new interfax.InterFax();
            long resultStatus = interfaxWebServiceOutbound.CancelFax(username, password, transactionID);
            if (resultStatus == 0)
            {
                Console.WriteLine(string.Format("Cancelled TID {0}.", transactionID));

            }
            else
            {
                Console.WriteLine(string.Format("Failed with error code {0}.", resultStatus));
            }
            Console.ReadLine(); // use this to keep console open (waiting for keypress) after it is finished
        }
    }
}