ahochsteger / gmail-processor

Gmail Processor is an open-source project that automates the processing of Gmail messages and attachments using Google Apps Script and execute actions (e.g. store attachments in a GDrive folder, log information in a spreadsheet) depending on matching criteria.

Home Page:http://ahochsteger.github.io/gmail-processor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

saving files from URLs in emails

chrismazanec opened this issue Β· comments

Is your feature request related to a problem? Please describe.
Some companies send URLs for download instead of the actual file (pdf) itself.

Describe the solution you'd like
I'd like the option for this URL to be extracted and the file saved to Google Drive

@chrismazanec thanks for this feature request, it sounds like a good feature to be added. :-)
The interesting part would be how to detect the relevant URLs to be downloaded (e.g. using a regex) without downloading each and every URL and how to deal with possibly multiple matching URLs.
Maybe you can describe your use case a bit with more details to better understand how this should work.

@ahochsteger this works /(https?:\/\/[^\s'"<>]+)/g for matching all URLs. relevant ones could be filtered/limited using extra var/regex, limiting the URLs to be downloaded. by default, all URLs could be downloaded (excluding duplicates).

the use case is for invoicing - a company sends a link to download the invoice instead of the actual attachment. successful download with curl requires setting the user agent to desktop browser.

@chrismazanec, would it be possible for you to test the PR #144 which implements the feature you requested?
You can use the script ID 1yhOQyl_xWtnGJn_bzlL7oA4d_q5KoMyZyWIqXDJX1SY7bi22_lpjMiQK and version 124 of the Gmail Processor Lib in Google Apps Script that points to a development snapshot containing these changes.
When you confirm that it's working, I'll merge the PR and create a new release.

πŸŽ‰ This issue has been resolved in version 2.3.0 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

I got to test this, and it works beautifully, thank you for your hard work!  πŸ™ (even better than I imagined)