Reputation: 53
I'm currently trying to make a program that pulls emails from a specified sender reads the .txt file attached to that email (contains my work schedule as a text file) and imports it into my calendar. I have almost everything working but always get these diamond-shaped characters each time I try to extract the text from the .txt file. This is the current code I'm using to extract it.
function testMain()
{
var emails = getEmailsBySender(sendersEmail);
Logger.log(emails[0].getAttachments()[0].getAllBlobs()[0].getDataAsString());
}
getEmailsBySender(sendersEmail)
is the function I wrote that returns the specific email with the text attachment. The response I keep getting looks like this ��1
. I also did some research and some people were suggesting adding an offset to getDataAsString()
like this getDataAsString('ISO-8859-1')
, but that just returned this ÿþ1
. Do I need to modify the offset again or am I missing something else?
Upvotes: 0
Views: 262
Reputation: 5852
GmailAttachment is already a blob. Please check the documentation.
emails[0].getAttachments()[0].getDataAsString()
Reference: GmailAttachment.getDataAsString
Upvotes: 1