...
To test this feature out, create a new Test Case, using the following Test Case Content:
|
Code Block |
---|
MIME-Version: 1.0 Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT) Date: Sun, 19 Jun 2011 17:42:26 +1200 Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com> Subject: This is a starting email template, update as required From: from@from.com To: oldTo@oldTo.com, changeme@thiswontwork.com cc: removeme@cc.com Content-Type: text/plain; charset=UTF-8 some text |
...
Code Block |
---|
/*Edit Headers*/ if(headerBeans.get('to') != null){ var toAddress = jemhUtils.getOriginalAddressees(headerBeans.get('to')); print('To Address Header values:', toAddress); var firstRecipient = toAddress.get(0); /*Set Address and Personal values of selected recipient*/ firstRecipient.setPersonal("changed recipient"); firstRecipient.setAddress("changed@changed.com"); var updatedHeader = jemhUtils.updatePreProcHeader(toAddress, headerBeans.get('to')); print(updatedHeader.getUpdatedVal()); print(updatedHeader.getUpdatedVal()); /*Replace Header with new value here*/ headerBeans.replace("to", updatedHeader); } |
|
Inserting new addresses into an existing Header
...
Code Block |
---|
/*Edit Headers*/ if(headerBeans.get('to') != null){ var toAddress = jemhUtils.getOriginalAddressees(headerBeans.get('to')); print('To Address Header values:', toAddress); /*create new address*/ var newAddress = jemhUtils.createInternetAddress('new', 'new@new.com'); /*adding new address to To header*/ toAddress.add(newAddress); var updatedHeader = jemhUtils.updatePreProcHeader(toAddress, headerBeans.get('to')); print(updatedHeader.getUpdatedVal()); print(updatedHeader.getUpdatedVal()); /*Replace Header with new value here*/ headerBeans.replace("to", updatedHeader); } |
|
Adding New Headers
Note |
---|
Any new Headers you wish to add must be listed the “Matching Headers” csv, or they will not be processed! |
...
Code Block |
---|
/* Adding a header */ var bccHeader = jemhUtils.addPreProcHeader('bcc', 'newBcc@newBcc.com'); if(bccHeader != null){ headerBeans.replace('bcc', bccHeader); print(headerBeans.get('bcc')); } |
|
Use Auditing to see the post-change email content
Once the mail is changed you can download both the original mail, and the Edited mail:
API Reference
$jemhUtils == http://ppl-docs.s3-website-us-east-1.amazonaws.com/JEMH/3.3.80/com/javahollic/jira/emh/api/IJEMHVelocityContextUtils.html
$headeBeans == https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html
preProcHeader class == http://ppl-docs.s3-website-us-east-1.amazonaws.com/JEMH/3.3.80/com/javahollic/jira/emh/api/preproc/PreProcHeaderBean.html
...