I have an automation that uses Outlook and a 3rd party system. Basically what I need to do is loop through all the mails in a specific folder and extract some of the mail data. This part is working fine with the “Get Outlook Mail Messages” activity and using System.Net.Mail.MailMessage.
However I then need to select the current mail item in Outlook and in the 3rd party system click import mail. This will import the selected mail into the system.
But how do I select the mail in Outlook?
We don’t have any direct activities to Select mails from Outlook.
May I know how you will do it manually ? You need to record the same steps here to automate this process.
Recording is not an option. Unfortunately UiPath Click activity does not seem to be working with Outlook when using either SendWindowsMessage or SimulateClick. Only the hardware-based option seem to be working and since the folder might not be visible potential scrolling will be required.
My hope was that somehow it was possible selecting the MailItem declared as System.Net.Mail.Mailmessage - or possible use Microsoft.Office.Interop.Outlook in some kind of way.
After get the emails from outlook, use for each activity, put TypeArgument property System.Net.Mail.MailMessage and in Values property type the variable output of get outlook mail message, and then you can get each mail item!
Not sure if I understand your solution entirely. But as of now I am using the Get Outlook Mail Message activity and output to mailItems wich is of type List<System.Net.Mail.Mailmessage>.
Then I loop through the list mailItems to process each mail. But still the mailItem is of type System.Net.Mail.Mailmessage and it really does not select the item within the folder in Outlook. How do you cast the System.Net.Mail.Mailmessage to an Outlook mailitem in Values property?
That’s what I already did - but that part does not select/highlight the actual mail within the mailbox - and that is required for the 3rd party system to import the mail. It will import the selected/highlighted mail in the mailbox.
I found one way tested by me that can solve your problem… you are able to use outlook app right?
Hi @jacchr what do u mean by select current mail item… Do u require mail body??
Yes - the Outlook app will be running as well…
No - I do not need the mail body… But the actual “mail item” in Outlook.
Ok so you first, inside the for each item, will need to attach window in outlook, and edit the selector of attach like this:
After that, you will need to type in the search bar the subject of email with type into activity with empty field checked and selectory like this:
Then, you will need to go to the dropdown in the right of search bar, and uso two clicks, one for open the dropdown, and other for select the option for list all emails in outlook.
Both will need to have dynamic selector:
My first click:
The click that selects the option, for prevention, in properties, type the delay after for 900 miliseconds for example:
I will post the rest solution after this reply, not able to write what I need, should be about the lenght of this reply.
Finally, you will need more one click activity, that one will go to click in the email item, the selector will need to be like this, using one fuzzy selector: