The following Google Apps Script code sends the email when the trigger runs and writes the date/time back to the spreadsheet as a record.
Confirmation of message delivery |
Using the 'GmailApp' we can 'getMessageById' since we have it stored in the spreadsheet (this is how we access the draft message) and subsequently extract the relevant parts:
var body = message.getBody();We then use a Try/Catch to 'sendEmail' (so the script does not just crash if it encounters an error), remove it from drafts ('moveToTrash') and finally 'setValue' of status Delivered along with the date/time this function began.
var options = {
cc: message.getCc(),
bcc: message.getBcc(),
htmlBody: body,
attachments: message.getAttachments()
}
Finally we delete the corresponding trigger by running the deleteTrigger function which will be described in a later blog post and 'clearContent' of the Schedule ID column.
No comments:
Post a Comment