Release notes #0.1.127.0
Email module​
The built-in email package can now send binary files, for example XLSX, PDF, DOCX, images and archives, as attachments.
What is new​
- email.sendSecureShare uploads binary attachments (
Buffer,Uint8Array,ArrayBuffer) as the original file bytes. Before, binary content was converted to text and the file was corrupted. Attachments of any type can be sent, including XLSX. - A string attachment can be passed together with
encodingset tobase64,hexorbinary. The string is decoded and the file contains the original bytes. - email.send supports binary attachments. This also works when a block is run from the Canvas debugger in the browser.
- email.attach keeps binary content as is. Objects and arrays are still converted to a JSON string.
email.attachsets the content type from the file extension (xlsx, xls, csv, txt, html, xml, json, pdf, doc, docx, ppt, pptx, zip, gz, png, jpg, gif, svg) ifcontentTypeis not specified. An explicitcontentTypeis always used if it is specified.- An attachment with empty binary content is reported with the error
File <name> doesn't have data.
Notes​
- In the browser debugger, a binary attachment with a content type that is not supported by the email service (for example XLSX or DOCX) is sent as
application/octet-stream. The file name and extension are kept. - Canvas does not provide libraries for creating XLSX or other binary files in block code. The block code has to provide the file bytes.
- Emails with attachments generated in block code may be filtered into the Spam folder by the recipient's mail system.