.Net Fax - Send a fax and check its status

This is a more advanced .Net code sample to show how to send a fax and then check the status of a fax that was submitted until the status indicates that the fax has been completed. This code sample is based on the .Net library for InterFAX available on Github.

This sample demonstrates how to send a fax with a PDF through InterFAX to a single recipient and then loop through checking the status of that fax until processing of the fax is completed in InterFAX - all you need to do in order to change it is to provide a different fax destination number and a path to a file.
A fax in InterFAX is completed when either the fax was sent successfully to the recipient (in which case, the fax status would be "0") or all of the call attempts for this fax have been completed and the fax was not sent fully (in which case the fax status would be > 0).

  
     // send a fax
var faxId = await interfax.Outbound.SendFax(
  interfax.Documents.BuildFaxDocument(@".\path\to\fax.pdf"),
  new SendOptions
  {
    FaxNumber = "+11111111112"
  }
);

// wait for the fax to be
// delivered successfully
while (true)
{
  // load the fax's status
  var fax = await interfax.Outbound.GetFaxRecord(faxId);
  // sleep if pending
  if (fax.Status < 0)
  {
    Thread.Sleep(10000);
  } else if (fax.Status == 0)
  {
    Debug.WriteLine("Sent!");
    break;
  } else
  {
    Debug.WriteLine($"Error: {fax.Status}");
    break;
  }
}

  

The status of the fax is only one of several parameters that you can retrieve in regards to a fax. For a full list, please review our API documentation.

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