Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Child pages (Children Display) | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
As opposed to the server routines, we use here full structures because we have access to the whole email.
IncomingMail
Code Block |
---|
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; |
IncomingEmailHeader
Code Block |
---|
string name;
string value; |
IncomingEmailAttachment
Code Block |
---|
string fileName;
string contentType;
int size;
byte [] content; |
Example usage
(provisional)
Code Block |
---|
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);
} |