I receive an email with a hyperlink that when clicked starts a download of a csv file to my Gmail account. It's not an actual attachment. When I receive this email (which has a unique subject line), I need a way to automatically add the contents of the downloaded .csv
Trigger: An email with a specific subject line is received to my gmail account
Action 1: Download a .csv file from a hyperlink within the body of the email
Action 2: Add the contents of the .csv file to a Google Sheet file
I need an already built service that does this or suggestions on how to approach it.
If I can get this Google script to run, I should be able to find a working solution. The problem is the script keeps giving me errors.
function downloadFile(fileURL,folder) {
var fileName = "";
var fileSize = 0;
var response = UrlFetchApp.fetch(fileURL, {muteHttpExceptions: true});
var rc = response.getResponseCode();
if (rc == 200) {
var fileBlob = response.getBlob()
var folder = DocsList.getFolder(folder);
if (folder != null) {
var file = folder.createFile(fileBlob);
fileName = file.getName();
fileSize = file.getSize();
}
}
var fileInfo = { "rc":rc, "fileName":fileName, "fileSize":fileSize };
return fileInfo;
}