Add attachment in compose email view.

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)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • In the Emails module you can attach a document stored in the Sugar's Documents module:

    1. Compose the Email: Start by composing your email in SugarCRM.
    2. Access the Attachment Menu: Locate the "Attachment" option in the email editor.
    3. Select "Sugar Document": Choose the "Sugar Document" option from the Attachment menu. This will open a search screen allowing you to find documents within SugarCRM.
    4. Search for the Document: Use the search interface to locate the specific document you want to attach.
    5. Select and Attach: Once you've found the document, select it, and it will be added as an attachment to your email.
    6. Send the Email: Complete your email and send it as usual. 
    would that work for your scenario?
    FrancescaS