Resolving problems when you use Email nodes

Advice for dealing with common problems that can arise when you develop message flows that contain Email nodes.

About this task

A negative email size displays in the local environment

Procedure

  • Scenario: The EmailInput node receives an email from an email server that supports Post Office Protocol 3 (POP3) but the size of the email, including any attachments, might display a negative value in the Root.EmailInputHeader.Size Multipurpose Internet Mail Extensions (MIME) logical tree.
  • Explanation: The email server provider that supports POP3 uses the TOP command to fetch the headers for the email message and the LIST command to determine the size of the entire message. The server then subtracts the two values to determine the size of the message body. If the server reports the size of the entire message incorrectly, you might see a negative number in the local environment Size field.
  • Solution: You can use a Compute node to calculate the size of the email message and the size of any attachments. The following example ESQL can be used to calculate the size of the email content and attachments for a multipart MIME document. In this example, the result is stored in the LocalEnvironment:
    DECLARE CURSOR REFERENCE TO InputRoot.MIME.Parts;
    		 		 DECLARE I INTEGER 0;
    
    		 		 FOR SOURCE AS CURSOR.Part[] DO
    		 		 		 SET I = I + LENGTH( SOURCE.Data.BLOB.BLOB);
    		 		 END FOR;
    		 		 
    		 		 SET OutputLocalEnvironment.Variables.EmailSize = I;

    For more information about messages that belong to the MIME domain, see Manipulating messages in the MIME domain.

A parsing error displays when you reparse an email attachment as XML

Procedure

  • Scenario: Your message flow retrieves emails from an email server by using an EmailInput node. The email contains an XML document attachment that you want to reparse. However, when you try to reparse the attachment you receive parsing errors from IBM® Integration Bus reporting that you have an invalid XML character.
  • Explanation: Some email servers might insert carriage return (CR) and line feed (LF) characters at the end of an email. Typically you would want to keep these characters, but in this scenario you must remove them so that you can reparse your XML data.
  • Solution: Use the following ESQL in a Compute node to remove the CR and LF characters:
    DECLARE NEWEMAIL BLOB TRIM( TRAILING X'0d0a' FROM InputRoot.
    MIME.Data.BLOB.BLOB );

Removing unwanted null characters from an email

Procedure

  • Scenario: Your email attachment contains unwanted null characters that you would like to remove.
  • Explanation: Your email attachment might contain null characters that you would like to remove; for example, you intend to reparse the data in the attachment.
  • Solution: Use the following ESQL in a Compute node to remove the null characters:
    DECLARE NEWEMAIL BLOB TRIM( TRAILING X'00' FROM InputRoot.MIME.
    Data.BLOB.BLOB)