C# Fax – Retrieve the Image of a Previously-Submitted File with GetFaxImage
Download the C# fax API zip file.
This sample demonstrates the GetFaxImage method, which retrieves the image of a previously-submitted (outbound) file using the C# Fax API.
The C# fax code snippet below retrieves the image of an outbound fax:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetFaxImage
{
class Program
{
static void Main(string[] args)
{
string username = "";
string password = "";
long transactionID = 546585833;
byte[] imageData = null;
// the image will be retrieved to imageData in bytes
interfax.InterFax interfaxWebServiceInbound = new interfax.InterFax();
long resultStatus = interfaxWebServiceInbound.GetFaxImage(username, password, transactionID, ref imageData);
if (resultStatus == 0)
{
System.IO.File.WriteAllBytes(string.Format("C:\\Docs\\Interfax\\{0}.tif", transactionID), imageData);
// the folders in the specified path must exist and the user must have write access to them
Console.WriteLine(string.Format("Image properly saved to C:\\Docs\\Interfax\\{0}.tif. Size (in bytes): {1}.", transactionID, imageData.Length));
// verbose
}
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
}
}
}