Annyoing incompatible datatypes for Append to List, Append to Collection, Send SMTP Mail Message

I’m trying to do something that should be very simple, create a list of screenshot paths and add to it for each exception, then use the collection for attachment to Send SMTP Mail Message.

If I go to Send SMTP Mail Message and CTRL+K to create the variable it creates it as IEnumerable<String> but then the Append Item to List and Append Items to Collection activities don’t accept that datatype.

Append Item to List tells me:

Append Items to Collection tells me:
image

And of course if I change the datatype of my variable to what either of those activities wants, then Send SMTP Mail Message won’t accept it.

You cannot add items to an IEnumerable

An ICollection is an IEnumerable, but can have items added, an IList inherits ICollection so is both a ICollection and an IEnumerable.

Make your variable into an List and the SMTP should accept it. If it says it wants an IEnumerable but wont accept a List<String then something weird is going on with the compiler but that can be fixed with a cast.

Of course you can add things to a variable that is IEnumerable datatype. It’s literally the datatype the Send SMTP Mail Message activity creates for you. The point is all these activities are using different types of collections, so they won’t work together.

I’m not sure what you are complaining about regarding the IEnumerable being the data type for the SMTP…? Its absolutely the correct one, it being an array, or List or Collection would be annoying because it would limit you to that data type.

Because its an IEnumerable, which is an interface that Array, List and Collection all inherit it means you can use all of those data types.

I’ve made it very clear what I’m complaining about and it’s a perfectly valid complaint. Please stop.

Sorry Paul, but if you want the data type for the SMTP activity to be changed from an IEnumerable then I don’t understand why. I have explained clearly why it is the correct data type.

Its important to counter point suggestions made like this as it can be things that lead to a worse state in the platform. Respectfully if you want to participate in community forums then you must accept other community members disagreeing with you.

I wrestled with this one again and finally found what I was looking for.

(UiPath.Mail.Activities v1.20.3)

The Send SMTP Email activity has a property AttachmentsCollection that is IEnumerable<string>. The one thing I couldn’t figure out is how to simply append a value to that collection.

With it defined as New List(Of String) in its default, the following expression will append an item to it:

Assign TransactionEmailAttachments = TransactionEmailAttachments.Concat({yourStrVar})

image