Syntax For Each to have one iteration, in other words loop only once

I’d like the For Each to have one iteration, in other words to loop only once.


What’s the syntax for this?


Can you try to use {Emails.First} instead of Emails at ListOfItems property?


For each will loop as many times there are items within the collection unless you break out of it.

What is the purpose of using the for each?

You can just work with the first item of the collection i.e. List(0)

YourMailMessagesVar.Take(1) for taking the first email
YourMailMessagesVar.Take(5) for taking the first 5 mails
YourMailMessagesVar.Skip(10).Take(1) taking the 11th mail

and so on

After the first iteration, break can be used at end of sequence.

1 Like

Looping once isn’t a loop, and is pointless.

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