Lukas R. Lukas R. - 8 days ago 5
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);
mailItem.Display(false);


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

I tried your code and is good. I think your trouble is in your Word program. Try fix it with this Microsoft utility: https://support.microsoft.com/it-it/kb/921541