Deletion of emails in variable Uipath.MicrosoftOffice365.models.MicrosoftOffice365Message[]

Greetings,
Currently I’ve been trying to remove or get mail from this variable through the add to collection or remove from collection activity, but I get this error: Remove From Collection: Collection was of a fixed size.

Do you know how I can do this in another way, either remove a specific email from the array or add it to a new array please?

@Giordy_Sanchez

Inside of removing in ForEach loop, why don’t you put a filter to get those emails only
You can use Query if you have to get those emails only?

Thanks,
Srini

@Giordy_Sanchez

If you want to delete that mail then use Delete email activity

Hope this may help you

Thanks,
Srini

Thank you for your answer, the issue is that I need to manage them through conditionals once already obtained, therefore I would like to be efficient and eliminate the emails on the variable in which I already obtained those emails

@Giordy_Sanchez

Instead of removing from the collection if your conditions are not satified then you can maintain another collection and once the conditions are satisfied you can add to that collection for further use

Hope this may help you

Thanks,
Srini

@Giordy_Sanchez

Ideally array is immutable…but you can try this

Varofc = varofc.ToList.Where(function(x) Not x.Subject.Contains("Subject you want to remove")).ToArray()

In place of “Subject you want to remove” you can use the subjectvariable as well

Hope this helps

Cheers

Hi @Giordy_Sanchez

It looks like collection you’re trying to modify has a fixed size, which cannot be changed dynamically.

You can follow these steps-

  1. Create a new collection or array to store the emails that you want to keep. For example, you can create a new empty array or collection to store the emails that you want to retain after removing the specific email.
  2. Iterate through the original array or collection that contains the emails.
  3. For each email in the original array or collection, check if it is the email that you want to remove. If it is not the email you want to remove, add it to the new array or collection that you created in step 1.
  4. Once you have iterated through all the emails in the original array or collection, the new array or collection will only contain the emails that you want to keep, with the specific email removed.

Thanks!!!

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