Qasim Iqbal Qasim Iqbal - 7 months ago 40
C# Question

How can i programmatically delete email attachments after I save them on my hard drive

So I am making an outlook add-in where I the program reads emails attachments and saves them in the windows:(c) directory. But i want the program to delete email attachments from the directory after program finish's reading the attachments.


string path = @"C:\\att\\" + attachment.FileName;


To delete a file: System.IO.File.Delete(path)

You could iterate through the files inside the folder

string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)