using System; using System.Collections.Generic; using TNZAPI.Messaging.Objects; using TNZAPI.Messaging.Send; using TNZAPI.Messaging.Functions; namespace TNZFaxAdvanced { class Program { static void Main(string[] args) { #region Declarations const string sender = "YOUR_EMAIL_ADDRESS"; const string api_key = "YOUR_API_KEY"; const string reference = "Test Fax - Advanced version"; const string recipient1 = "+6491231234"; const string recipient2 = "+6471231234"; const string recipient3 = "+6461231234"; const string recipient4 = "+6441231234"; const string file1 = "C:\\file1.pdf"; const string file2 = "C:\\file2.pdf"; const string file3 = "C:\\file3.pdf"; const string file4 = "C:\\file4.pdf"; const string resolution = "High"; const string csid = "TEST FAX"; const int retry_attempts = 3; const int retry_period = 1; #endregion Declarations Fax FaxMessage = new Fax(sender, api_key); #region Add Recipients // // Add Recipient Method 1 - AddRecipient(string recipient); // FaxMessage.AddRecipient(recipient1); // // Add Recipient Method 2 - AddRecipient(new Recipient()) // Recipient recipient = new Recipient(recipient2); recipient.CompanyName = "Test Company"; // Company Name recipient.Attention = "Test Recipient 2"; // Attention recipient.Custom1 = "Custom1"; // Custom1 recipient.Custom2 = "Custom2"; // Custom2 recipient.Custom3 = "Custom3"; // Custom3 recipient.Custom4 = "Custom4"; // Custom4 recipient.Custom5 = "Custom5"; // Custom5 FaxMessage.AddRecipient(recipient); // // Add Recipient Method 3 - AddRecipients(new List<Recipient>()); using simple destination // List<Recipient> recipients = new List<Recipient>(); recipients.Add(new Recipient(recipient3)); // // Add Recipient Method 4 - AddRecipients(new List<Recipient>()) using Recipient objects // recipients.Add(new Recipient( recipient4, // Recipient "Test Company", // Company Name "Test Recipient 4", // Attention "Custom1", // Custom1 "Custom2", // Custom2 "Custom3", // Custom3 "Custom4", // Custom4 "Custom5" // Custom5 )); FaxMessage.AddRecipients(recipients); #endregion Add Recipients #region Add Attachments // // Add Attachment Method 1 - AddAttachment(file_location); // FaxMessage.AddAttachment(file1); // // Add Attachment Method 2 - AddAttachment(new Attachment()); // Attachment attachment = new Attachment(); attachment.FileName = FileHandlers.GetFileName(file2); attachment.FileContent = FileHandlers.GetFileContents(file2); FaxMessage.AddAttachment(attachment); // // Add Attachment Method 3 - AddAttachments(new List<Attachment>()) using simple file locations // List<Attachment> attachments = new List<Attachment>(); attachments.Add(new Attachment(file3)); // // Add Attachment Method 4 - AddAttachments(new List<Attachment>()) using Attachment objects // attachments.Add(new Attachment( FileHandlers.GetFileName(file4), FileHandlers.GetFileContents(file4) )); FaxMessage.AddAttachments(attachments); #endregion Add Attachments MessageResult response = FaxMessage.SendMessage( "", // MessageID - Leave blank to auto-generate reference, // Reference new DateTime(), // SendTime "New Zealand", // Timezone "", // SubAccount "", // Department "", // ChargeCode resolution, // Resolution - High/Low csid, // CSID "", // WaterMarkFolder "", // WaterMarkFirstPage "", // WaterMarkAllPages retry_attempts, // RetryAttempts - no of retries retry_period // RetryPeriod - no of minutes between retries ); if (response.Result == MessageResult.ResultCode.Success) { Console.WriteLine("Success - " + response.MessageID); } else { Console.WriteLine("Error - " + response.ErrorMessage); } } } }