Qasim Iqbal Qasim Iqbal - 1 year ago 73
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;

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download