As a first step, since an email search can result in multiple emails, customize your automation project to handle multiple emails in the search context.
-
SAP Build Process Automaton comes handy with several loop controls. Add a Forever loop activity after Log Message. You can read more about it from the documentation.
-
Forever loop needs to make sure it is executed until there is one email in the search result. In order to know this, use Check Current Email activity which will return if there is any pending emails in the search context. Kindly make sure to test an appropriate output parameter for this activity.
While looping use Get Next Email (Context), and move the loop needle. -
The output of Get Next Email (Context) activity step is a boolean.
-
The result of the previous step will return true if an email exists in the search context, stop the loop when there are no more emails to process. You use the Condition Expression Editor and include Is not or ! on the boolean output parameter from previous step. Add the given expression through the expression editor and close it.
-
Add a Log Message that loop has reached its end. You can give a custom message if you wanted.
-
Add an appropriate log message to this step.
-
If none of the conditions are met, the workflow of the automation will continue through the default branch. Now to the default branch, you can log the loop index first. Log Message comes handy during debugging. You may remove it, in case you no longer need them.
-
You can optionally include a custom log message.
-
For each email in the loop context, let us retrieve its email Subject through Get Mail Subject activity.
-
Add a log message to print the email subject.
-
To the log message event, add your custom message
-
Add Get Next Email (Context) activity to advance the loop variable.
-
Save and Test the automation, you should see appropriate results.
-
You can include additional attributes related to your email in search context result. For example, see the various activities you can use to retrieve additional attributes in your search context.
At this stage, you converted your project to process a series of emails in the search context. An Email may contain one or more file attachments. In the next step, you will download the file attachments.