I need to get attachment name from Email. However, when there are more than 1 attachment (let’s say 3 attachments), I can only get the very first one .
Can anyone knows how to get all attachment names in one Email.
Currently, I use the following method to get the attachment name.
If you have an object of MailMessage, you can use below method to get array of its attachment names.
mailMessage.Attachments.Select(function(x) x.Name)
The return is an array so you need assign it to a IEnumerable variable or immediately for each it or add index after expression in your case like below.
attachementName1 = item.Attachments.Select(function(x) x.Name)(0)
You need not for each your attachments beforehand.