To help others, the TypeArgument’ property is RELATED to the ‘ITEM’ property! It is NOT a property as a property meant to be related to the [Add To Collection]-activity. As its name should be self-explanatory, in my opinion, it is not.
Several users, including me, has faced trouble implementing an [Add To Collection]-activity, easily ending up with error messages like “…are you missing a cast?” because of ‘one type’ can’t be converted into ‘another type’ or whatever other ‘datatype’ mismatch, reason, misjudging the ‘property’ TypeArgument.
On several video’s, experienced users, explain the using of a ‘to my idea at least’ strange notation ‘ New List(Of String()) ’. Actually not for VB .Net users. Note, I have nothing against VB .Net honestly, don’t blame me, I simply lost connection with this directive. So, for C# users, new List() sounds more familiar.
An [Add To Collection]-activity is merely used in conjunction with setting up a list of attachments to be hooked on a [Send Mail Message]-activity.
An attachment list is just a list of comma separated strings, like in Python [“A”, “B”, “3”]. In C# UiPath such a list is instantiated as new List()
See screenshot: ‘attachmentList.
As in several tutorials, video’s, etc. is shown, an [Add To Collection]-activity is implemented within a [For Each]-activity. Each ‘item’ should be stored in that collection. Note, that such a collection can hold literally everything including a simple list of strings. This is actually the confusing trap!
The ‘TypeArgument’ property is RELATED to the ‘ITEM’ property and sure NOT to the ‘Collection’ property in the [Add To Collection]-activity.
Keep in mind, the ‘item’ is coming from the [For Each]-activity, most times it is simple string. The data type of the item is going to be the value of the TypeArgument. The ‘attachmentList’-variable, as said, is instantiated as a list of strings. This object is going to be filled up with strings of attachments.
This object (data typed as List in which T is a ‘string’) is hooked-up within the AttachmentCollection (data typed as InArgument<IEnumerable>).