Skip to content

Instantly share code, notes, and snippets.

@sheharyarn
Last active July 23, 2020 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheharyarn/fb7db10c1bf67a22d585879bcd11775a to your computer and use it in GitHub Desktop.
Save sheharyarn/fb7db10c1bf67a22d585879bcd11775a to your computer and use it in GitHub Desktop.
Google Appscript to auto-reply to recruiters
function respondToEmails() {
//var filter = 'from:(some.email@address.com) AND -label:"Auto-Replied"';
var filter = 'label:"Job Proposals" AND -label:"Auto-Replied"';
var completeLabel = GmailApp.getUserLabelByName("Auto-Replied");
var threads = GmailApp.search(filter);
var replyFrom = "Recruiter Bot <your.email+recruiterbot@gmail.com>";
val realEmail = "your.real@email.com"
var formLink = "https://link.to/your/form"
var response = (
"Hello, dear recruiter!" +
"\n\n<br/><br/>" +
"Thank you for getting in touch! I receive a lot of job proposals, " +
"so I have a form to collect all the important information for me. Please " +
"click the link below and spend a few minutes describing the job. " +
"That will help me get all the data I need:" +
"\n\n<br/><br/>" +
"<code>" + formLink + "</code>" +
"\n\n<br/><br/>" +
"Best Regards," +
"\n<br/>" +
"<b>Sheharyar Naseer</b>" +
"\n\n<br/><br/>" +
"---" +
"\n\n<br/><br/>" +
"<i>Did the bot incorrectly categorize you as a recruiter? If so, you can send me an email directly at: " + realEmail + "</i>" +
"\n\n<br/><br/>"
);
for (var i = 0; i < threads.length; i++) {
var subject = threads[i].getFirstMessageSubject();
var id = threads[i].getId();
Logger.log("[New Email Found]: " + id + "(" + subject + ")");
threads[i].reply("", {htmlBody: response, from: replyFrom});
threads[i].addLabel(completeLabel)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment