We can trigger an email using through our message mapping using Java's standard API and notify if certain conditions are met or not met based on the requirements. We can use the same functionality in JAVA mapping to trigger an email with the help of Operation mapping.
In this post I will try to cover the triggering of an email through UDF.
Prerequisites:
We need to use import the jar file as imported archive in ESR(This jar contains standard Java Mail API).
You can download the zip from the below link. You need to import it as Imported Archive in ESR.
https://sites.google.com/site/learnsappiblogspotcom/a-rapid-journey-to-sap-xi-pi/mail.zip?attredirects=0&d=1
We require the following parameters to trigger an email.
After importing this zip file go through below steps.
Step1: After successful import of archive. Create a UDF sendEmail in message mapping.
(Suppose our UDF triggers email when Header Text is "Final".)
Note: you can create your own logic based on the requirement.
Step2: Assign your archive in tab Archive used.

Step3: import the package as below.

Step4: Now we need to find SMTP host and simply provide details.
For SMTP host we need to follow below steps:
Goto tcode SCOT in PI system and click on SMTP.
Then you will get below popup

Copy the mailhost from the above path.
Step4: Write the udf( Below udf is written if incoming field is "Final". The mail will be send if input to udf is Final else mail will not be triggered.)

This will be helpful if you are sending email on the basis of some incoming payload in Message.
Note: Email will be triggered every time when we execute either message mapping or Operation mapping.
In this post I will try to cover the triggering of an email through UDF.
Prerequisites:
We need to use import the jar file as imported archive in ESR(This jar contains standard Java Mail API).
You can download the zip from the below link. You need to import it as Imported Archive in ESR.
https://sites.google.com/site/learnsappiblogspotcom/a-rapid-journey-to-sap-xi-pi/mail.zip?attredirects=0&d=1
We require the following parameters to trigger an email.
- Sender host
- Recipient List
- Subject
- Message
- Sender
Step1: After successful import of archive. Create a UDF sendEmail in message mapping.
(Suppose our UDF triggers email when Header Text is "Final".)
Note: you can create your own logic based on the requirement.
Step2: Assign your archive in tab Archive used.
Step3: import the package as below.
Step4: Now we need to find SMTP host and simply provide details.
For SMTP host we need to follow below steps:
Goto tcode SCOT in PI system and click on SMTP.
Then you will get below popup
Copy the mailhost from the above path.
Step4: Write the udf( Below udf is written if incoming field is "Final". The mail will be send if input to udf is Final else mail will not be triggered.)
This will be helpful if you are sending email on the basis of some incoming payload in Message.
Note: Email will be triggered every time when we execute either message mapping or Operation mapping.