Datatable - Value of type 'System.Collections.Generic.List(Of System.Net.Mail.MailMessage)' cannot be converted to 'System.Data.DataTable'

I’m using Get Outlook Message to generate a datatable type - System.Collections.Generic.List(Of System.Net.Mail.MailMessage) and would like to clear this table after process is completed. I’m unable to do so due to “Clear Data Table” activity error shown below.

Has anyone encounter this issue and can advise on how to resolve this?

Validation Error

Compiler error(s) encountered processing expression “EmailMessages”.
Value of type ‘System.Collections.Generic.List(Of System.Net.Mail.MailMessage)’ cannot be converted to ‘System.Data.DataTable’.

Hi,

System.Collections.Generic.List(Of System.Net.Mail.MailMessage) is not DataTable but List.
So, can you try to use Clear Collection activity as the following?

Regards,

2 Likes

Thanks for the swift reply. I can only use clear collection in a linear process like what you have here. Unfortunately, in my scenario the "List " trigger a flow decision. After this workflow complete is when i want to clear collection to allow get Outlook mail to decide the direction of my Flow Decision.

For this reason the same List cannot be cleared before the IF workflow. And when I place it after, the loop remain stuck in one direction (List present → Unread message)

I even tried to duplicate the List via assign before clear collection of list specific to the Flow Decision. Again, The loop remain stuck in one direction (List present → Unread message)

Did not matter if i moved clear collection to before my IF workfolw, and After (as pictured here).

Something i realize is using assigned links both "List " so clearing list 1 also affect list 2.

A possible solution would be to copy from List 1 to List 2 making them independent but I’m clueless if this is possible

Workflow picture

Hi,

Can you try the following expression? This copies all values to new Llist (not reference).

newList = new List(Of System.Net.Mail.MailMessage)(oldList)

Regards,

1 Like