Create multiple issues from multiple To/Cc addresses in specific projects.

How to create issues in separate projects when an email is received containing multiple To and/or Cc addresses. issue properties can be specified for each email address that's included in the script.

var support = false; var i2500 = false; var rosterChange = false; //create a defaulat issue resultMap.put("labels", "hello-world"); resultMap.put("FORCE_JEMH_SCRIPTFP", true); for (i =0 ; i < toAddresses.length ; i++) { var toEmailAddress = toAddresses[i].getAddress(); if(toEmailAddress.equalsIgnoreCase("support@example.com")) { support = true; } else if(toEmailAddress.equalsIgnoreCase("2500@example.com")) { i2500 = true; } else if(toEmailAddress.equalsIgnoreCase("rosterchange@example.com")) { rosterChange = true; } } //for CC email addresses /*for (i =0 ; i < ccAddresses.length ; i++) { var ccEmailAddress = ccAddresses[i].getAddress(); if(ccEmailAddress.equalsIgnoreCase("support@example.com")) { support = true; } else if(ccEmailAddress.equalsIgnoreCase("2500@example.com")) { i2500 = true; } else if(ccEmailAddress.equalsIgnoreCase("rosterchange@example.com")) { rosterChange = true; } }*/ if (support) { var newResultSet = jemhUtils.createResultSet(); newResultSet.put("project", "SUP"); newResultSet.put("issueType", "bug"); newResultSet.put("priority", "low"); newResultSet.put("reporter", "admin"); newResultSet.put("body", "do this.... \n"+ body); } if (i2500) { var newResultSet = jemhUtils.createResultSet(); newResultSet.put("project", "ADV"); newResultSet.put("issueType", "task"); newResultSet.put("priority", "low"); newResultSet.put("reporter", "admin"); newResultSet.put("body", "do this.... \n"+ body); } if (rosterChange) { var newResultSet = jemhUtils.createResultSet(); newResultSet.put("project", "AOLM"); newResultSet.put("issueType", "bug"); newResultSet.put("priority", "low"); newResultSet.put("reporter", "admin"); newResultSet.put("body", "do this.... \n"+ body); } if (!support && !i2500 && !rosterChange) { print("none of the following addresses were found: support@example.com, 2500@example.com, rosterchange@example.com"); } print("Done")