I am using Google Apps Script to automate saving attachments from emails to unique Google Drive folders depending on the Label the messages have been filtered into.
So far I have managed to get the message ID using some code snippet I have found on line. However I am stuck trying to access the body of the messages & save the attachment to drive folders.
function getMessage(){
var folder = DriveApp.getFolderById('xxxxxxxxxxxxx');
var userId = "[email protected]";
var query = "label:Global Alcohol";
var res = Gmail.Users.Messages.list(userId, {q: query});
var attachment = msgs.Attachments.get(userId, messageId, id);
var ids = res.messages.map(function(e){return e.id});
Logger.log(ids);// Message IDs with the specific labels.
}
Thanks in advance for your help.