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.
Really appreciate your prompt response.
Actually this is what I was trying to do but facing some implementation issues .
So basically my flow should be -
1. Newmail arrives
2. Start interaction - interaction started event
3. Start activity for key
4. Activity started event triggering the actual automation that involves download & upload to application etc.
5. Closing the interaction - wait for event for NewMail
Also, I tried the second option using lock component but that is also not working. After the new mail event , I am putting RequestLock ( with no timeout interval) .
The requirement is that after downloading the attachment, the bot has to start a windows application, do an upload on that application and then send a reply mail through outlook. Now during the complete process , I am not using any asynchronous link or something that should break the thread but still the automation is not able to lock the process. What could be the issue ?
I would have uploaded a screenshot for your reference but I am bound by org policies. Please Help!
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.
The automation is not working as expected.Its doing the process for 1 mail but not working fine for 2 mails sent simultaneously.
This is what I am doing -
1.Runtime Host project started event --> start interaction method (interaction key set to 1)
2.NewMail event --> start activity method
3.Activity started event --> execute method of the main automation.
Just FYI the main automation is downloading an attachment for a particular mail, uploading the same to a windows application and post the upload it is replying back on the same mail to the sender.So the last method that is called in this automation is an "outlook send method" to reply back .
What could be the possible issue or mistake with this flow?
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