Get Mails error
I'm pretty new here. I've been playing around with OpenRPA and Node Red for a few days, looking for a framework for building RPA bots.
It looks pretty good. However, I run into trouble handling Outlook - emails.
(not sure this the right place to ask this...)
What I want to accomplish is:
- Open Outlook,
- Find the latest unread mail in a specific folder.
- Save the attachment(s) if any.
- Get some other well formatted data from the mail
...) and then do other stuff with the obtained data and attachment(s).
But I get stuck at the second step already.
- Open Application (select Outlook) ==> OK
- GetMails Filter: ???
DisplayName: Get Mails
I think the first problem is with the Output property.
I type [Ctrl]k listMail. A variable is automatically created of type IEnumerable<email> (sounds reasonable to me)
Then the output shows:
#The following errors were encountered while processing the workflow tree:
'DynamicActivity': The private implementation of activity '1: DynamicActivity' has the following validation error: Compiler error(s) encountered processing expression "listMail".
Type 'email' is not defined.
As robot handling of emails is probably used a lot, I must be doing something wrong...(?)
Allan Zimmermann last edited by
Hi @rjvanschoonhove, I'm still trying to find a good balance of helping the user and not "over doing it" when it comes to auto importing namespaces. So the reason you get the first error is your missing the namespace OpenRPA.Office under the imports tab
but you do not need to create a list variable, the whole point of having a body in most activities is that this body can then become your "for each" ... so using "get email" this will list subject of all emails
( click the "refresh" icon, while outlook is open to make the activity list all folders it can see, then select a folder )
Next, to save all emails you can simply call
but if you need more control ( decide file names or filter out certain attachments you can add a "ForEachWithBodyFactory" and select type as OpenRPA.Office.Activities.Attachment
and then call item.SaveTo("c:\temp", True)
Thank you for your quick and accurate response! (I only saw that you responsed this morning).
I got it to work.
It is all very sensitive w.r. to where you click:
If I select Outlook (OpenApplication) and click on the account-name (instead of on the Inbox), the folder (Inbox\Test) won't be found.
If I select the target folder right away, then the script only succeeds if (Outlook is already open AND that folder is already selected).
I didn't get it to work on another account in the same outlook instance. (Refesh with Outlook open will populate the drop-down-box with items of 1 account).
I may figure out later how to select folders of another account.
But it does work and I still need to learn a lot.
I also got rid of the error when trying to store the <email> (list).
I had tried to edit the XAML file on the Open project overview page directly, but failed. Imports are the way to go.
Thanks again and kind regards,