Change Content-type of email
This example will show how to fix incorrect Content-Type of an email.
Test Case Example
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: "Andy Brook" <andy@localhost>
To: changeme@thiswontwork.com
Content-Type: text/plain; charset=UTF-8
some text
Script example
var fromAddress = jemhUtils.getOriginalAddressees(headerBeans.get('from')).get(0).getAddress();
if (fromAddress != null){
print('From address: ' + fromAddress);
if (fromAddress.equals('andy@localhost')){
var ct = headerBeans.get('content-type');
var contentType = ct.getOriginalVal();
print('Old content-type:' + contentType);
if (contentType.startsWith('text/plain')){
contentType = contentType.replace('text/plain','text/html');
ct.setUpdatedVal(contentType);
contentType = ct.getUpdatedVal();
print('New content-type: ' + contentType);
}
}
}