I am attempting to make my own version of Boomerang, a script that returns emails to your inbox at a later time as specified by the user.
I am using Google Apps Script and I have everything working except I can't return the email to the top of the inbox. I've tried forwarding the email with the relevant script, but to no avail.
Any thoughts?
Here's a few examples of the code I've tried (none of which produce the result I'm looking for):
Test 1:
messages = GmailApp.getMessagesForThreads(threads);
for (var i = 0 ; i < threads.length; i++) {
messages[i][0].reply("<b>This message has been moved to the top of your inbox per your request. Please take action soon.</b>", {
replyTo: "[email protected]"
});
}
Test 2:
messages = GmailApp.getMessagesForThreads(threads);
for (var i = 0 ; i < threads.length; i++) {
forward("[email protected]", {
htmlBody: "<b>This message has been moved to the top of your inbox per your request. Please take action soon.</b>",
name: "ServAce85",
replyTo: "[email protected]",
from: "[email protected]",
subject: "Re: " + messages[i].getSubject()
});
}
Test 3:
messages = GmailApp.getMessagesForThreads(threads);
for (var i = 0 ; i < threads.length; i++) {
messages[i][0].forward("[email protected]", {
subject: messages[i][0].getSubject()
});
}
Test 4:
function moveEmail(threadsToMove) {
var threads = threadsToMove;
var messages = GmailApp.getMessagesForThreads(threads);
for (var i = 0 ; i < threads.length; i++) {
messages[i][0].forward(Session.getActiveUser().getEmail(), {
subject: "Re: " + messages[i][0].getSubject(),
htmlBody: "<b>This message has been moved to the top of your inbox per your request. Please take action soon.</b></n>" + Session.getActiveUser().getEmail() + "</n>" + messages[i][0].getBody()
});
GmailApp.sendEmail(Session.getActiveUser().getEmail(), "Re: " + messages[i][0].getSubject(), messages[i][0].getPermalink());
}
}