Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function maintenanceRequest() {
- var findFirstRequest = GmailApp.search("to:censored label:ems-request AND is:unread", 0, 1)[0];
- var firstRequest = findFirstRequest.getMessages()[0];
- var parseRequest = firstRequest.getPlainBody();
- var requestString = String(parseRequest);
- if ("Mark archived mail as read" == requestString) {
- markArchivedAsRead();
- findFirstRequest.moveToArchive();
- }
- else if ("Cleanup" == requestString) {
- weeklyCleanup();
- findFirstRequest.moveToArchive();
- }
- else {
- GmailApp.sendEmail("censored", "Failure to parse command", "The EMS has recieved your request but has failed to recognize the command '" + parseRequest + "'. Please try again, using the terms 'Mark archived as read' or 'Cleanup'. If you would like to add an eligible command, please refer to function 'maintenanceRequest'.", {
- name: "Email Maintenance Service",
- from: "censored"
- })
- //Add moveToArchive line here after debugging
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement