I've been using RSS2Email to turn Gmail into Google Reader.
I'd like to create a Google Apps Script to do this instead, to get two advantages:
The scheduling would be handled by Google Apps Script. (No need to have a dedicated computer to run the script.)
The resulting emails would be labeled per-feed, nicely organizing things.
Using Google Apps Script would be the same implementation spirit as e.g. Gmail Snooze.
I understand how to fetch the feeds. Where I'm stuck is how to create the emails using a specific label. The approaches I've investigated so far:
- The Gmail Service for Google Apps Scripts doesn't allow this, at least not obviously.
GmailApp.sendEmaildoesn't let you specify a label. Which makes sense since this is for generic email sending. But ...GmailApp.sendEmailreturnsGmailApp, not something you could use to ID the message and change its label later.- The service also doesn't appear to let you create Gmail filters programatically, ruling out another possible way to tackle this.
- The Gmail Migration API would be perfect to do this -- but it doesn't work for normal, consumer Gmail accounts. Gah.
- Google's IMAP extensions might allow this, but it's unclear to me.
I suppose I could use 1, putting some UID in the Subject that I could use to look up the delivered message, to add the label (and hopefully un-uglify the Subject by removing the UID). But that seems a bit kludgy.
Using 3, IMAP extensions, seems possibly less kludgy, although probably much more work to code and test.
Any recommendations among these? Is there some other API or strategy?
The Google Apps Script GmailApp API does not give a way to add a label to a message as you send it, something you can do from the UI. This appears as Issue 1859 in the issue tracker, visit and star it for updates.
A work-around would be to take advantage of the thread apis. If the message is blind-copied (bcc'd) to the sender, it will also appear as a new message in their inbox, where we can use
getInboxThreads()to find it. Add the label to this thread, and optionally mark it read then archive it.Code also available as a gist.
Example of use: