I have a function which sends an email with mutiple attachments but I have hit a problem. Once the files have been attached and the email sent, I cannot access the files until processes are recycled. After some research, I understand that I need to add "dispose" the attachments after I have sent the email, the problem is that all the examples I have seen only show one attachment being sent and then releasing the file. Here is the basis for the code:
protected void sendEmail(string toEmail, string subject, string body, List<String> attachments)
{
System.Net.Mail.Attachment data;
string toCC = "";
try
{
.....
Code to pull information from DB and process data
.....
foreach (string attachment in attachments)
{
data = new Attachment(attachment);
MyMailMessage.Atta ...
Go to the complete details ...