We can use an IMAP Matcher in application flow.
(Example)
The application fails with java.lang.NullPointerException if Subject of an Email is Null. The error stack looks like something like below.
ERROR 2020-03-25 11:29:34,477 [[MuleRuntime].cpuLight.03: [sample].sample_Flow.CPU_LITE @540943a9] [event: 0-694c0a10-6ead-11ea-9914-005056ac7599] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: ******************************************************************************** Message : Error while retrieving emails: null. Element : sample_Flow/processors/2 @ sample:sample.xml:293 (For Each) Element XML : <foreach doc:name="For Each" doc:id="c7e7b348-16e9-4235-bc0d-c01bbecb7214"> Error type : MULE:UNKNOWN Payload Type : org.mule.runtime.core.internal.streaming.object.ManagedCursorIteratorProvider -------------------------------------------------------------------------------- Root Exception stack trace: java.lang.NullPointerException at java.util.regex.Matcher.getTextLength(Matcher.java:1283) at java.util.regex.Matcher.reset(Matcher.java:309) at java.util.regex.Matcher.<init>(Matcher.java:229) at java.util.regex.Pattern.matcher(Pattern.java:1093) at java.util.regex.Pattern.lambda$asPredicate$0(Pattern.java:5770) at org.mule.extension.email.api.predicate.BaseEmailPredicateBuilder.lambda$build$0(BaseEmailPredicateBuilder.java:94
While the IMAP Matcher was dealing with Subjects of Emails and if there is an Email that has null Subject, "java.util.regex.Matcher.getTextLength" will detect NullPointerException as printed in the Stack.
To filter Email Subject that will have null value, we can use Choise router to filter Subject and to check if the Subject is Not null.
(Example)
<choice doc:name="Choice" doc:id="3a6d013c-a100-42df-a14b-6664ef661611" > <when expression="#[(attributes.subject != null) and (attributes.subject contains 'Validated')]">
001123568

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.