Remove mail from list of mail messages

Hey guys

I want to remove a an email from my collection if it contains:

E.g. .com instead of .net inside the for each mail → mail.From.ToString

But i get an error as seen in the picture and i cant find any solution for that:

IMPORTANT NOTE: It reads though the first 2 mails and returns TRUE because they contain the string i want. But when it returns FALSE on the email that contains NOT the string i want then it removes it and right after gives me that error.

Hi @Ibra

You can try this -

Thanks,
Prankur

1 Like

Thank you for the input Prankurjoshi.

But i want to remove it from the collection because im using the collection in other workflows and i dont want those particular mails to be read other places.

Okay, so that error is because you are trying to delete something in between of an enumeration loop, that is not allowed

Hmm i see… Whats the alternative way to accomplish this?

Easiest way should be to add filtered messages to new collection in the same loop and pass this collection to required workflow.

Or if its helpful there is an inbuilt Filter property in Get OutLook Mail Messages Activity

image

image

Thanks,
Prankur

I tried with the following syntax:

“[From]=‘.com’”

And all the other strings like .net, .dk etc but it returned null all the time

Instead of removing from the collection, am keeping no activity in the then filed(means not doing anything just ignoring), and am adding activities in the else filed.

this is solved the issue.

if it goes to else filed then am saving that emails to folder by using save email/save attachments.