What are the different ways to trigger the job whenever new mail is received in the Outlook mailbox?
There are some possible ways to achieve the requested scenario. Use any of the below approaches which suits best according to the business request,
- This approach needs a dedicated Robot which is running just to monitor the Mail box and take appropriate action of executing other jobs.
- In case the job is not required to immediately run as soon as the email arrives, schedule to move the required data in email to UiPath queue and make other Processes consume the Queue data. This utilizes the dedicated Robot used in Option 1.
There are three kinds of trigger parameters available for the queue. Go through this link Queue Trigger to know about a detailed explanation of queue triggers.
- In case customization is needed, try triggering the Robot from Outlook Rules. Write a batch script which will trigger the jobs from outlook rules when the email arrives. Outlooks Rules And Alerts Run A Script
Create a VB script in Outlook to monitor incoming emails and when a new one appears in the Inbox to trigger a CMD command to run the Robot.
UiPath support does not build such scripts, but list some suggestions :
- Open the Outlook and press ALT+F11, it will open VB for application Studio
- In the Microsoft Outlook Objects select This Outlook session
- Example presented in this website can be modified : How To Run A VBA Macro When New Mail Is Received In Outlook, instead of message box execute a CMD command to run the xaml file (Robot workflow that processes the email) , as in this example on how to run the xaml file from the command line "C:\Program Files (x86)\UiPath\Studio\UiRobot.exe" /file:"C:\Users\UserName\Documents\UiPath\LogProcess\Main.xaml"
Whenever the job is run from the command prompt and if the Robot is connected to Orchestrator it will only write the logs in the database, but the job will not be visible in the Orchestrator.
If jobs need to be logged to Orchestrator make use of API calls, so whenever a new email is received, make an API post to that specific job, the job will start from Orchestrator and it will be logged properly.
For more information about APIs access our documentation Building API Requests .