Reputation: 23
I have a Google Script that processes the inbox looking for missing e-mails, and then sends out a summary of missing e-mails to my inbox:
var user;
var summary = "";
Logger.log("Checking last emails...");
user_list.forEach(function(user) {
var no_user_hit = true;
var query = 'from:'+user.user+' in:anywhere newer_than:' + user.deadline + 'd';
Logger.log(query);
var threads = GmailApp.search(query);
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
if (check_subject(messages[j].getSubject(), user.subject)) {
no_user_hit = false;
}
}
}
if (no_user_hit == true) {
Logger.log("Sending email with summary...");
summary = summary + "No messages from "+user.user+" with subject "+user.subject+" for the last "+user.deadline+" days \n";
}
});
if (summary.length > 0) {
GmailApp.sendEmail(me, email_subject_to_your, summary);
}
}
I would like to star each e-mail being sent as a summary, I have tried starMessage(message) but that hasn't worked out.
Upvotes: 1
Views: 853
Reputation: 12129
The problem appears to be that the GmailApp.starMessage() accepts a GmailMessage object, but you are supplying the method with a string (as seen from the error message you are getting).
After you have sent your message, you will need to find it again in user's mailbox and then star it.
There is an answered question about retrieving a just-sent message for further processing - that might help with this.
Upvotes: 1