Limit Filter or Divide Arrays by Element Location

Here is my situation. I have two arrays. First array is array of pdf files. Second Array is Array of Order Numbers. I need to send an outlook email with attachments. But will limit the Attachments and Order Numbers, by the number of variabl “EndIndex”. For example. I have 5 items both arrays, and “EndIndex=2”. I will send an Email with Attachment1 and 2, as well as ordernumber1 and 2. Then the next loop is Attachment3 and 4, OrderNumber 3 and 4 and so on. Until I finished sending all the Attachments.

Is there a way to limit, get, divide, filter an array. To get a specific range of element location? I hope you can help me Thank you.

Hi @Shinjid

What will happen of the 5th attachment and order number?

You can group the array elements as per your need and then send the attachments as per that new group. Group can be stored in a list, array

Below is the syntax for list:
NumberOfItems is the total number of elements in array, can be found using .length function

(From i In Enumerable.Range(0,NumberOfItems).ToList
Select ArrayOfLines.Skip(i*2).Take(NumberOfItems).toArray).toList

Just replace 2 with the number you want, or create a variable out of it. That will decide number of group elements in one group.

How this helps!

It would be send on alone. So I have an odd number of Array elements with even counter. The last one would be sent alone.

Tried printing it using for each. But the first loop prints all of the items(I have 5 so it prints it all). Next loops prints 3(5-2), It prints ArrayElement 2,3,4 then next Loop prints only Element 4. And since it has 5 arrays, last two arrays in the list is empty

Hi @Shinjid

Try this

Limit Filter or Divide Arrays by Element Location.xaml (10.2 KB)

That just groups. I have used it and works just fine for the case you mentioned above.

I’ll try to send you the xaml to showcase the working.