CSDNCurrent en:E Mail Notifications
Disabling e-mail notifications on server-side
Usually the Cryptshare Server manages all e-mail communication between the participants of a transfer. However, when developing an own client application for Cryptshare communication it might be desirable to send these notifications from within this client. Therefore Cryptshare allows it to disable the sender and the recipient notification for each transfer.
Disabling the sender notification for a transfer Transfer transfer = new Transfer(); transfer.notifySender = false; Disabling the recipient notification for a transfer Transfer transfer = new Transfer(); transfer.notifyRecipients = false;
Developers of a Cryptshare Client Application might want to handle transfer notifications themselves, for instance for an e-mail integration such as Cryptshare for Office 365 & Outlook. In order to still have the same layout and especially the unique information per recipient the API offers the possibility to request the HTML code for the e-mail notification from the server.
client.RequestMailTemplate("<template-name>", <replacements>, <language>, <mailFormat>);
<template-name> : The name of the desired e-mail template <replacements> : Mapping of the placeholders in the template <language> : The language of the template <mailFormat> : The mail format which shall be used. This can either be 'HTML' or 'plain'
E-Mail Placeholders
E-Mail placeholders are used to fill in individual information into the templates. This way each e-mail recipient can retrieve an e-mail with unique content, such as the personal download link, name or e-mail address.
Template Snippet with name and e-mail placeholders
[...] <p>Dear Sir or Madam,</p> <p>Confidential data has been sent to you by <a href="mailto:$email">$name</a>. [...]
Possible placeholders in e-mail notifications
The following table shows available placeholders in e-mail templates. Placeholders tagged with
SENDER are specifically required for the sender template. Placeholders tagged with
RECIPIENT are specifically required for the recipient template.
Tag | Placeholder Key | Description | Additional Notes |
---|---|---|---|
SENDER RECIPIENT |
TemplatePlaceholder.BASEURL |
The Cryptshare Server URL | |
RECIPIENT |
TemplatePlaceholder.SUBJECT |
The message subject | |
RECIPIENT |
TemplatePlaceholder.MESSAGE |
The body of the message | |
SENDERRECIPIENT |
TemplatePlaceholder.DATE_1 |
The expiration date of the transfer | |
SENDERRECIPIENT |
TemplatePlaceholder.LIST_3 |
The list of the files in the transfer | |
RECIPIENT |
TemplatePlaceholder.LINKREF |
The download link for the transfer | |
SENDERRECIPIENT |
TemplatePlaceholder.PASSWORDMODE |
The type of password mode used for the transfer |
Possible values:
|
RECIPIENT |
TemplatePlaceholder.NAME |
The name of the sender | |
RECIPIENT |
TemplatePlaceholder.PHONE |
The phone number of the sender | |
RECIPIENT |
TemplatePlaceholder.EMAIL |
The e-mail address of the sender | |
SENDERRECIPIENT |
TemplatePlaceholder.LIST_1 |
List of the recipients addressed in 'To' | |
SENDERRECIPIENT |
TemplatePlaceholder.LIST_2 |
List of the recipients addressed in 'Cc' |
How to use e-mail placeholders
#client.RequestMailTemplate() requires a very specific replacement-map in order to get the desired result. The parameter is a set holding instances of type TemplateReplacement. A TemplateReplacement object is basically a key-value wrapper where the key is a specific placeholder enum and the value can either be a list or a single value. This allows it to retrieve customized templates per recipient with a single request.
Using placeholders // <replacements> Dictionary<ISet<string>, ISet<TemplateReplacement>> replacements = new Dictionary<ISet<string>, ISet<TemplateReplacement>>(); // <replacementSet> ISet<TemplateReplacement> replacementSet = new HashSet<TemplateReplacement>(); replacementSet.Add(new TemplateReplacement(TemplatePlaceholder.NAME, "John Adams")); replacementSet.Add(new TemplateReplacement(TemplatePlaceholder.EMAIL, "john.adams@server.com")); List<string> fileList = new List<string>(); fileList.Add("file_01.txt"); fileList.Add("file_02.docx"); replacementSet.Add(new TemplateReplacement(TemplatePlaceholder.LIST_3, fileList)); List<string> recipientList = new List<string>(); recipientList.Add("recipient1@otherdomain.org"); recipientList.Add("recipient2@otherdomain.com"); replacementSet.Add(new TemplateReplacement(TemplatePlaceholder.LIST_1, recipientList)); // <identifiers> ISet<string> identifiers = new HashSet<string>(); identifiers.UnionWith(recipientList); replacements[identifiers] = replacementSet; MailTemplateResult mailTemplates = client.RequestMailTemplate("recipient", replacements, System.Globalization.CultureInfo.CreateSpecificCulture("ja"), "html");
<templateName> : The name of the desired e-mail template
<replacements> : Mapping between <identifiers> and <replacementSet>
<identifiers> : Set of e-mail addresses which have a specific <replacementSet>
<replacementSet> : A set of placeholders for <identifiers>
The result object of an e-mail template request
When requesting an e-mail template using #client.RequestMailTemplate() the returned mapping contains a unique template per identifier-set. This means with one request a filled in template can be returned per single recipient or for all recipients together or for a combination of both.
Example: multiple <identifier>-<replacementSet> combinations // identifiers1: One single recipient, replacementSet1: Set of replacements replacements[identifiers1] = replacementSet1; // identifiers2: Two recipients, replacementSet2: Set of replacements replacements[identifiers2] = replacementSet2; MailTemplateResult mailTemplates = client.RequestMailTemplate("recipient", replacements, System.Globalization.CultureInfo.CreateSpecificCulture("ja"), "html");
The above request would return two templates, one for each set of identifiers put into the replacement map both having a different content, meaning the placeholders have been filled in with the contents of replacementSet1, respectively replacementSet2.