Send your first message
In this example we will use the keys and the EndPoint to send a first message. That code sample send a simple message by email without files.
internal class Program
{
static Guid serial = new Guid("CF97C28F-CEAE-4FE3-B5CE-1D65AFF21039");
static Guid APIuser = new Guid("42A24D7D-256C-4671-86C0-3381CFA228DC");
static Guid APIpassword = new Guid("8097AF06-ADAD-4FB5-ADAF-C0AEF84727FF");
static Uri endpoint = new Uri("https://www.secure-exchanges.com/_api/0217/0217.asmx");
static void Main(string[] args)
{
// Create a recipient list and add a recipient
List<RecipientInfo> recipientList = new List<RecipientInfo>();
recipientList.Add(new RecipientInfo() { Email = "example@secure-exchanges.com" });
// The message you want to send. That string could be HTML
string message = "My <strong>HTML</strong> message";
// The subject of the email
string subject = "My subject";
// Set a password to your message
string password = null;
// Use that list to set binary files
List<FileArgs> binaryFiles = new List<FileArgs>();
// The method you want to use to send your message the supported values are
// onlyEmail => Send only by email
// onlySMS => Send only by SMS
// msgEmailCodeSMS => The message will be send by email, and the dynamic opening code will be sent by SMS
// msgSMSCodeEmail => The message will be send by sms and the dynamic opening code will be sent by email
var sendMethod = SecureExchangesSDK.SecureExchanges.SendMethodEnum.onlyEmail;
// Set to true to send with your own Smtp server
bool sendByMyOwnSMTPServer = false;
// The subject will be show
bool showSubject = true;
// Set this parameter to false if you don't want to be notify by email on opening
bool getNotify = true;
// Set the culture of the message, the supported culture are fr-CA and en-CA
string culture = "en-CA";
// The number of time that the message will be allowed to be open by the recipient
int maxOpeningTime = 5;
// The delay in minutes before your message expired, the maximum time is 43200 (30 days)
int expirationMinutes = 30;
// Create MutliRecipientArgs that contains message arguments.
// Here in our exemple we need SDK keys, endPoint, recipients list,
// message text, subject, culture, max open time and minute expiration
var arg = new SecureExchangesSDK.Models.Args.MutliRecipientArgs(
endpoint, serial, APIuser, APIpassword, recipientList,
message, subject, password, binaryFiles,
sendMethod, sendByMyOwnSMTPServer, showSubject,
getNotify, culture, maxOpeningTime, expirationMinutes
);
// We call MultiRecipientMessage with the arguments to send the message to the recipients.
// We get a MultiRecipientAnswer.
var messageAnswer = SecureExchangesSDK.Helpers.MessageHelper.MultiRecipientMessage(arg);
// The status code 200 mean the message has been sent with success.
if (messageAnswer.Status == 200)
{
Console.WriteLine("Your message has been sent successfully");
foreach(var recipientAnswer in messageAnswer.RecipientsAnswer)
{
// that is the answer for each recipient in the list
Console.WriteLine($"The status is {recipientAnswer.Answer.Status}");
Console.WriteLine($"The url of the message is {recipientAnswer.Answer.URL}");
Console.WriteLine($"The HTML of the message is {recipientAnswer.Answer.HtmlMsg}");
}
}
// If someting wrong you will find the reason in the data properties
else
{
Console.WriteLine(messageAnswer.Data); // the reason why the call fail
}
}
}