Reputation: 17
I am trying to store the text content of Gmail attachments to Google Drive. I followed steps mentioned here and got a basic OCR script working: https://medium.com/@aio.phnompenh/make-ocr-tool-in-google-spreadsheet-to-extract-text-from-image-or-pdf-using-google-app-script-c478d4062b8c
This performs OCR on the image linked in valueURL below:
var image = UrlFetchApp.fetch(valueURL).getBlob();
However, when I try to reference it to a Gmail attachment using:
var image = GmailApp.getInboxThreads()[0].getMessages()[0].getAttachments();
I get the error:
The mediaData parameter only supports Blob types for upload.
Can someone let me know how do I resolve this?
Regards.
Upvotes: 0
Views: 451
Reputation: 5892
The .getAttachments()
function returns a array of GmailAttachment[] objects. To get the first attachment or even the only attachment you need to do this:
var image = GmailApp.getInboxThreads()[0].getMessages()[0].getAttachments()[0];
Upvotes: 1