Learn SAP CPI Groovy Mapping - Set Dynamic MAIL recipient by applying Rule based logic on Inbound message payload

Part 3

Parse incoming XML Input message then based on Recipient field value of the message that is configured to match in External Parameters ‘CodeRequired’, filter and set the Recipient field of the MAIL connector dynamically

Parsing Dynamic XML Record and Set Email Recipients using Groovy

Iflow accepts XML input of two records, based on recipient field value which is set to 100 for testing the Groovy script will set the (dynamic recipients) email property in MAIL connector of iflow as 100@abusinesstech.com for code = 100, for code = 200 set the property in iflow as 200@abusinesstech.com

Create a simple iflow to read Incoming XML message

Create a property externalized to create Email Recipient selection rule based on this field

Write below script to set the recipient email address based on value maintained in the external parameter CodeRequired

or create more code based email recipient like below for CodeRequired = 200

Set the Mail Connector recipient configuration field to read the value of To: from property Recipient

Send the records of the incoming payload to the Dynamic Recipient list as Attachment.

Test the iflow by setting the value of external parameter as 100 or 200, Deploy it.

Testing the script by sending input XML message with Recipient field set to 100, using Postman

Message processed successfully

Email Sent to right RECIPIENT 100@abusinesstech.com , email address is set correct as per Rule maintained in the Groovy script rules Dynamically.