First message in 5 minutes
Send an encrypted message to one recipient, and let Secure Exchanges send them the email.
Prerequisites
- The package for your language installed: Choose your package.
- Your three preview credentials: Credentials and environments.
The complete code
using System;
using System.Collections.Generic;
using SecureExchangesSDK.Helpers;
using SecureExchangesSDK.Models.Args;
using SecureExchangesSDK.Models.Entity;
using SecureExchangesSDK.SecureExchanges;
internal static class FirstMessage
{
private static void Main()
{
// Your credentials come from your secret store, never from code.
Guid serial = ReadSecret("SecureExchanges:Serial");
Guid apiUser = ReadSecret("SecureExchanges:ApiUser");
Guid apiPassword = ReadSecret("SecureExchanges:ApiPassword");
// Production. For the preview environment, see "Credentials and environments".
var endpoint = new Uri("https://www.secure-exchanges.com/_api/0217/0217.asmx");
var recipients = new List<RecipientInfo>
{
new RecipientInfo { Email = "recipient@example.com" }
};
var args = new MutliRecipientArgs(
endPointUri: endpoint, serial: serial, user: apiUser, psw: apiPassword,
recipients: recipients,
message: "Hello, here is a secure message.",
subject: "Confidential message",
password: null, filesList: null,
sendMode: SendMethodEnum.onlyEmail,
getBackHtml: false, // Secure Exchanges sends the email
showSubject: true, // obsolete, no effect, but required by the constructor
getNotify: true,
cultureID: "en-CA",
maximumOpenTime: 5, // number of allowed openings
minutesExpiration: 1440); // 24 hours
var response = MessageHelper.MultiRecipientMessage(args);
// The link given to the recipient grants access to the message: do not log it.
if (response.Status == 200)
Console.WriteLine($"Sent to {response.RecipientsAnswer.Count} recipient(s).");
else
Console.WriteLine($"Failed, status {response.Status}"); // see Status codes
}
private static Guid ReadSecret(string name)
{
// Replace with a read from your secret manager (Azure Key Vault, etc.).
throw new NotImplementedException(name);
}
}
Important
Who sends the email to the recipient? With getBackHtml set to false, Secure Exchanges sends it. With true, the SDK returns the email as HTML and your application must send it.
Warning
true is the default value. If your recipient receives nothing, check this option first.
Check that it works
The status returned by MultiRecipientMessage must be 200. The recipient receives an email with their link and reads the message on the Secure Exchanges secure page.