Thursday, April 06, 2023

Gmail Script

 function autoReply() {

var label = GmailApp.getUserLabelByName('reject'); // Change 'reject' to the label name you want to use
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
var thread = threads[i];
var messages = thread.getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];
// Change the signature of the reply message as per your requirement
var replyBody = "Hi - thanks for contacting me about this opportunity. After review*, it does not appear to be fit.\n\nIf you'd like more specifics about why it's not a fit, please ask.\n\nThanks,\n______\n\n* Notes: If you've emailed me multiple times, you may receive multiple copies of this note. In some cases, the review is performed automatically without me even seeing the email based on certain words or phrases in your email. Also, please check your database. I may be replying from a different email address than the one you emailed. This is the correct one (__@gmail.com) for all recruiter communications.\n---\n+ Looking for an Email Marketing job? https://emailmktgjobs.blogspot.com/\n+ Connect with me on LinkedIn: https://www.linkedin.com/in/___/\n+ Schedule a call: ___";

if (message.getFrom.getAddress === '_____@gmail.com' || message.getFrom.getAddress === '______@gmail.com') {
// Do nothing.
return;
}
GmailApp.sendEmail(message.getFrom(), 'Re: ' + message.getSubject(), replyBody);
thread.removeLabel(label);
thread.moveToTrash();
}
}

var label = GmailApp.getUserLabelByName('_SHARE');
var removelabel1 = GmailApp.getUserLabelByName('_WAITING');
var removelabel2 = GmailApp.getUserLabelByName('LINKEDIN');

var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
var thread = threads[i];
var messages = thread.getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];

thread.removeLabel(removelabel1);
thread.removeLabel(removelabel2);
GmailApp.moveThreadToArchive(thread);
GmailApp.markThreadUnread(thread);
}
}

var label = GmailApp.getUserLabelByName('_WAITING');
var removelabel1 = GmailApp.getUserLabelByName('LINKEDIN');

var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
var thread = threads[i];
var messages = thread.getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];

thread.removeLabel(removelabel1);
GmailApp.moveThreadToArchive(thread);
GmailApp.markThreadUnread(thread);
}
}

var label = GmailApp.getUserLabelByName('rate');
var addlabel = GmailApp.getUserLabelByName('_WAITING');
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
var thread = threads[i];
var messages = thread.getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];
// Change the signature of the reply message as per your requirement
var replyBody = "Thanks for sharing this role. What's the budgeted compensation range?\n(Per California state law - see below - this should have been included in the original email.)\n\nThanks,\n______\n\nPay Transparency Laws: \n* The salary range must be posted -- even if the role is ultimately performed elsewhere -- if it *could* be performed in California, Colorado, Washington state as well as New York City; Westchester County, NY; Ithaca, NY and Jersey City, NJ. Also effective for New York State on 9/17/2023. Statewide laws are currently being considered in Massachusetts, South Carolina and Tennessee. \n* Recruiters must provide the salary range - if requested - if the candidate lives in Connecticut, Maryland or Rhode Island.\n* It is illegal to ask for someone's salary history if they live in California, Colorado, Connecticut, Delaware, Hawaii, Illinois, Maine, Maryland, Massachusetts, Missouri, Nevada, New Jersey, New York State, Oregon, Puerto Rico, Rhode Island, Vermont and Washington state. Also Atlanta; Cincinnati; Columbia, SC; Louisville; New Orleans; Toledo; Philadelphia and Richland County, SC. Note: In Alabama, you can ask for it, but if you discriminate against a prospective candidate who refuses to provide, they can sue you.\n---\n+ Looking for an Email Marketing job? https://emailmktgjobs.blogspot.com/\n+ Connect with me on LinkedIn: https://www.linkedin.com/in/_____/\n+ Schedule a call: https://calendly.com/____";
GmailApp.sendEmail(message.getFrom(), 'Re: ' + message.getSubject(), replyBody);
thread.removeLabel(label);
thread.addLabel(addlabel);
GmailApp.moveThreadToArchive(thread);
GmailApp.markThreadUnread(thread);
}
}

}

No comments: