Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Affected Headers will show changes and additions:

...

Changing Headers

Example Test Case

To test this feature out, create a new Test Case, using the following Test Case Content:

Image Added

 

 

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 

Altering Existing Header Values

Note

Any Headers you wish to alter must be in the Matching Headers csv, or they will not be processed!

This example will alter the first recipient in the To address header, changing its value:

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); 
}
Image Added

 

Inserting new addresses into an existing Header

Note

Any Headers you wish to alter must be in the Matching Headers csv, or they will not be processed!

This example will alter the existing To address header, and will insert a new recipient into the To 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); 
}
Image Added

 

Adding New Headers

Note

Any new Headers you wish to add must be listed the “Matching Headers” csv, or they will not be processed!

This example will add the Bcc address header, with the provided values:

Code Block
/* Adding a header */ 
var bccHeader = jemhUtils.addPreProcHeader('bcc', 'newBcc@newBcc.com'); 
if(bccHeader != null){ 
  headerBeans.replace('bcc', bccHeader); 
  print(headerBeans.get('bcc')); 
} 
Image Added

 

API Reference

...