Posted: 12 Dec 2017 10:03 EST Last activity: 16 Mar 2021 4:05 EDT
NewMail Event in Robotic Automation
Requirement - Automation should be triggered the moment a New mail comes post which it has to download the attachment and upload it to an application, after this process is completed, it has to wait for another new mail and repeat the process.
Problem - During bot execution, if another new mail comes, the automation execution flow is going back to the latest "New Mail" that came without completing the process of downloading and uploading the attachment to the application.
How can we handle this situation so that the process is completed for the first new mail and only post which it is repeated for the second one ?
You should be starting an activity to trigger the automation when a new mail arrives. Since activities are queued, only one can execute at a time. This is what I would do.
The other option is to use the Lock component. When a new mail arrives, you can request a lock. When it returns True, you can trigger your automation. Once it completes, you would release the lock. When another request comes in while a lock has already been requested, it will get held at the RequestLock method until either the lock is released or until the timeout has been reached (I believe the timeout is in minutes or seconds instead of milliseconds). I would not use this component for this purpose though. I would use an activity.
You do not need the interaction. You could simply start an activity without a key. Since you are using the NewMail event to trigger the activity, there is really no waiting. On startup, you might check your Inbox to see if any arrived while you were offline, but otherwise, your flow is correct.
When the runtime is on and I receive the first mail. A NewMail event is getting triggered which in turn triggers my activity so the execution flow goes to my main automation ( which is triggered by the activity started event ) , Now at this point when the main automation is running, the second "New Mail" event is getting triggered and flow is going back and the proxy values for outlook mail and attachment are changing as a result of this NewMail Event