Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function maintenanceRequest() {
  2.  
  3.  
  4. var findFirstRequest = GmailApp.search("to:censored label:ems-request AND is:unread", 0, 1)[0];
  5. var firstRequest = findFirstRequest.getMessages()[0];
  6. var parseRequest = firstRequest.getPlainBody();
  7. var requestString = String(parseRequest);
  8.  
  9. if ("Mark archived mail as read" == requestString) {
  10. markArchivedAsRead();
  11. findFirstRequest.moveToArchive();
  12. }
  13. else if ("Cleanup" == requestString) {
  14. weeklyCleanup();
  15. findFirstRequest.moveToArchive();
  16. }
  17. else {
  18. 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'.", {
  19. name: "Email Maintenance Service",
  20. from: "censored"
  21. })
  22. //Add moveToArchive line here after debugging
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement