Email Listener: Removing Unwanted Text From Incoming Emails via Scripting
PeteHalbeisen 060001VQWA Comments (3) Visits (13027)
Summary: In this blog entry we will present a method to customize the removal of patterns of characters from incoming email HTML message bodies before they become part of free form SR long descriptions. We'll do this using the Automation Scripting application.
Here's a collection of non-IBM Maximo HTML weirdness -- mostly email, some from the web -- collected without actively seeking it out. It comes from sources such as LinkedIn, Google Translate, USA Cycling, WSJ and Outlook. We see weird alignments and extraneous characters that we expect to see hidden as part of the raw HTML of the document.
When the Email Listener receives incoming free form emails, the content is written directly to the SR long description without any processing. The raw bodies of HTML emails are like snowflakes, but there may be a pattern of characters or formatting common to all or some of those emails, which based on the tolerance of the customer, may range from a minor annoyance to a problem that they want resolved. There is no one size fits all approach and in the listener application we will not hard code HTML processing. The listener is the thing-in-the-middle subjected to the vagaries of an email system and the rich text editor; enter the Maximo Automation Scripting application, the perfect tool for customized solutions.
Below is sample source code for the simple utility class that we'll call from a Maximo automation script. Ensure the compiled class is placed in the binary folder indicated below as this will ensure when the script calls the class (via import statement) it will be in the correct location. Update the path and the Java package declaration to suit your desired package name. Here's a quick introduction to compiling a program Esse
Source placement: appl
Binary placement: appl
Once the class is compiled and the new ear is deployed, we're ready to log in, set up the script in the Automation Scripting application and perform an email test.
Next we'll send a test email. This email contains an example of each of the items we want stripped out of the email body before it hits the long description: a style section, a comment, some non-breaking spaces and an image tag which will be orphaned (though an image specified as attachment via email header will be attached as a document to the record - see Emai
Once the listener picks up the message, we'll go directly to the database to see the fruits of our labors. Voilà!