Skip to content

Instantly share code, notes, and snippets.

@trevorfoskett
Created November 5, 2019 21:03
Show Gist options
  • Save trevorfoskett/89dc6ac540aa51dfa5cf87bb6785ff20 to your computer and use it in GitHub Desktop.
Save trevorfoskett/89dc6ac540aa51dfa5cf87bb6785ff20 to your computer and use it in GitHub Desktop.
Updated Virtru encrypt client to allow the emailing of the protected file.
const client = new Virtru.Client({email});
const encryptParams = new Virtru.EncryptParamsBuilder()
.withArrayBufferSource(arrayBuffer)
.withDisplayFilename(`${docTitle}.pdf`)
.withPolicy(policy)
.withUsersWithAccess(authorizedUsers)
.build();
const ct = await client.encrypt(encryptParams);
var ctString = await ct.toString(); // Encrypt to string rather than to file
// Run server-side function to generate an email
// to the list of authorized users and include
// the HTML generated above as an attachment.
var userMessage = $('#email-body').val().replace(/\n/g, '<br/>');
// Take user input from a field in the sidebar and preserve line breaks
google.script.run.sendEmail(ctString, authorizedUsers, userMessage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment