You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 6 Next »
As opposed to the server routines, we use here full structures because we have access to the whole email.
string subject; string body; string htmlBody; string [] to; string [] cc; string [] from; string [] replyTo; IncomingEmailHeader [] headers; IncomingEmailAttachment [] attachments; string contentType; date sentAt; date receivedAt; int size; IncomingMail [] embeddedMessages;
string name; string value;
string fileName; string contentType; int size; byte [] content;
(provisional)
IncomingEmail mail = getIncomingEmail(); string issueKey = matchText(mail.subject, "[A-Z][A-Z]+-[0-9]+"); // find an issue key in the subject if(isNull(issueKey)) { // if no issue key found, create a new issue string [] fields = {}; fields += {"reporter", currentUserKey()}; fields += {"assignee", getUserByEmail(mail.cc[0]).key}; string newIssue = createIssue("TEST", "", "Task", mail.subject, "Minor", mail.body, {}, "", "", 0, fields); attachAllFilesFromEmail(newIssue); %newIssue%.watchers = getUserKeysFromEmails(mail.cc); } else { // if issue key found in subject, add a comment addComment(issueKey, currentUserKey(), mail.body); }