My aim to convert an email's content, with attachments, into a binary large object (blob) format within the Gmail add-on. I'm getting the body content using the below function but I'm not able to convert it into blob format.
I referred to the following documents but I don't know which function I have to use here for blob format.
function loadAddon(event){
var accessToken = event.gmail.accessToken;
var messageId = event.gmail.messageId;
GmailApp.setCurrentMessageAccessToken(accessToken);
var mailMessage = GmailApp.getMessageById(messageId);
var emailContent = mailMessage.getBody();
console.log("Email Content: " + emailContent);
}
Can anyone guide me on this?
In order to create a blob of the eml format, please modify the script as follows.
function loadAddon(event) {
var accessToken = event.gmail.accessToken;
var messageId = event.gmail.messageId;
GmailApp.setCurrentMessageAccessToken(accessToken);
var mailMessage = GmailApp.getMessageById(messageId);
var emailContent = mailMessage.getBody();
console.log("Email Content: " + emailContent);
var blob = Utilities.newBlob(mailMessage.getRawContent(), "message/rfc822", "sampleFilename.eml");
}
Utilities.newBlob(mailMessage.getRawContent(), "message/rfc822", "sampleFilename.eml")
.