I'm using Microsoft.Office.Interop.MailItem to strip attachements from email, save them to disk, print them out and then delete them from disk. I'm having problems deleting JPG attachements, the file seems to have a lock,
Here is my code for saving each attachement,
foreach (Attachment attachment in outLookMessage.Attachments)
{
var fileNameOnDisk = FileNameOnDisk(printFileFolder, attachment.FileName);
attachment.SaveAsFile(fileNameOnDisk);
}
I'm not sure why there is a lock on the JPG file. Is there any way I can release this log so that I can delete the file?