Last active
August 29, 2015 14:25
-
-
Save MauricioMoraes/145ce3f36fdb025e0300 to your computer and use it in GitHub Desktop.
Google Apps Script Function to get the first gmail draft from your account and output its attributes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFirstGmailDraftAttributes() { | |
var draftThreads = GmailApp.search("in:drafts", 0, 1); | |
if (draftThreads.length === 0) { | |
Browser.msgBox("No drafts found."); | |
return | |
} | |
var draft = draftThreads[0].getMessages()[0]; | |
var draftAttributes = { | |
id: draft.getId(), | |
subject: draft.getSubject(), | |
to: draft.getTo(), | |
cc: draft.getCc(), | |
bcc: draft.getBcc(), | |
body: draft.getBody(), | |
attachments: draft.getAttachments() | |
} | |
return draftAttributes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: Showing the subject for the first draft in your gmail account.