I have some code that I am using to send an email with an attachment. The next thing I wanted to do was add attachments from a string array or a List. I had a google but I could only find attachments from byte arrays. Is it possible to do something like this?
Attachment[] attachments = new Attachment(string array);
mail.Attachments.Add(attachments);
I know that won’t compile but just so you get the idea. Or is the only way to foreach an array and create attachments one at a time? Thanks.
There is no
AddRangeon anAttachmentCollectionso you’re out of luck doing it as a slick one-liner (short of creating an extension method). You could use something like this: