Get list of mails from "For Each Mail" activity


we are working on a process that has to do a lot of Outlook interactions - download attachments, move mails around, etc. And we are trying different ways to do it. The first option was using the desktop app with regular “Get Outlook messages” activities, but that causes problems with syncing the changes across different machines, as we are using a shared mailbox.

Now, we are looking into the “Use Outlook 365” activity. It looks like it does not have a simple “Get messages” type of activity, where we would get a list of messages, but instead the “For each mail” activity should be used. This would cause quite a lot of changes in our process flow, as majority of it would end up inside the loop, and that is not perfect. I was wondering, is there a way to get the list of messages that the loop iterates over? I was trying the debug, and experimenting with the Immediate window, but could not get the list, just the current message of the iteration.

Is this even possible? any other suggestions?
The regular Office365 activities do not work for us because the Azure AD app needs admin privilege, and that is against internal policies.

Actually this activity itself will give list of Mailmessage as output

And most of the mail activity gives the output in that same type

But we can still try with GET OUTLOOK MAIL activity itself
and mention the shared mail box

Have a view on this for more ideas


We can try using get exchange mail activities
For more details

Cheers @SSavickas

Thank you for the response. I understand that “Get Outlook mail messages” gets the list as an output, but the issue is that it uses desktop app, which is not reliable. I am interested specifically about the outputs of “For each mail” activity.

Exchange is an interesting option, it seems to work with a registered Azure AD app and a one-time consent grant.

Does anyone know if the consent granted here, or in O365 Scope, with the “Interactive” setting, is ever dropped?

As an alternate you can check by:

  • prepare a list(of MailMessages) - myMailMessages
  • For each mail - add within the loop the current mail to the list: myMailMessages

then again you will get the same output as in the past and used it for the already existing implementation

1 Like


The following might help you.

mails = Exchange.Folder("Inbox")

Note: mails is IEnumerable<MailMessage>type.


1 Like

thanks everyone, ended up using exchange activities with o365 settings, but all suggestions were really good!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.