I have extend compose.js file. In this file I want to add attachment. For attachment I have create custom endpoint and in this endpoint I'm getting pdf row data. I can convert this row data and tried to attached as attachment but it's not work.
compose.js code.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fetchAndAttachPDF: function () {
var self = this;
var email = this.model;
app.api.call('GET', app.api.buildURL('ComposeEmailAttachPdfApi/getBase64'), null, {
success: function (response) {
var filename = response.filename || 'Report.pdf';
var base64 = response.base64data;
var mimeType = response.mimeType || 'application/pdf';
try {
// Convert base64 to Blob
var byteCharacters = atob(base64);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var fileBlob = new Blob([byteArray], { type: mimeType });
// Create a File object (optional fallback name)