using System; using System.Collections; using System.Collections.Generic; using TNZAPI.Messaging.Objects; using TNZAPI.Messaging.Send; using TNZAPI.Messaging.Functions; namespace TNZSMSAdvanced { 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 SMS - Advanced version"; const string sms_email_reply = "REPLY_EMAIL_ADDRESS"; const string force_gsm_chars = "True"; const string recipient1 = "64211231234"; const string recipient2 = "64221231234"; const string recipient3 = "64231231234"; const string recipient4 = "64241231234"; 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 message_text = "Test SMS Message [[File1]] | [[File2]] | [[File3]] | [[File4]]"; #endregion Declarations SMS SMSMessage = new SMS(sender, api_key); #region Add Recipients // // Add Recipient Method 1 - AddRecipient(string recipient); // SMSMessage.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 SMSMessage.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 )); SMSMessage.AddRecipients(recipients); #endregion Add Recipients #region Add Attachments /* * Please note: * * Attachments are only supported with MessageLink - Please ask us to enable MessageLink * * Attachments will get ignored if you have not MessageLink functionality */ // // Add Attachment Method 1 - AddAttachment(file_location); // SMSMessage.AddAttachment(file1); // // Add Attachment Method 2 - AddAttachment(new Attachment()); // Attachment attachment = new Attachment(); attachment.FileName = FileHandlers.GetFileName(file2); attachment.FileContent = FileHandlers.GetFileContents(file2); SMSMessage.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) )); SMSMessage.AddAttachments(attachments); #endregion Add Attachments MessageResult response = SMSMessage.SendMessage( "", // MessageID - Leave blank to auto-generate reference, // Reference new DateTime(), // SendTime "New Zealand", // Timezone "", // SubAccount "", // Department "", // ChargeCode sms_email_reply, // SMSEmailReply - For email (SMTP) reply receipt notifications force_gsm_chars, // ForceGSMChars message_text ); if (response.Result == MessageResult.ResultCode.Success) { Console.WriteLine("Success - " + response.MessageID); } else { Console.WriteLine("Error - " + response.ErrorMessage); } } } }