Lukas R. Lukas R. - 1 year ago 179
C# Question

C# Outlook VSTO mailItem.SaveAs Word Document Premission Error

Hy guys i have the Problem that if i try to save a Outlook MailItem as Document to my Desktop i get this error:

The save operation can not be completed by Outlook due to a file permission error.

My code looks like this:

String fileName = Subject + ".doc";
String path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName);
mailItem.SaveAs(path, Outlook.OlSaveAsType.olDoc);

I already tryed to set Desktop as a trusted FileLocation in the Word Trust Center but it didnt work. I get the same error then before.

Does someone know how i can reslove that?

Answer Source

I tried your code and is good. I think your trouble is in your Word program. Try fix it with this Microsoft utility:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download