Attachment Not Found - 'System.IO.FileNotFoundException' RRS feed

  • Question

  • An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll but was not handled in user code

    Additional information: Could not find file 'mail1-highres-screen.png'.

    I keep getting this error when trying to deal with an attachment. Basically says it doesn't exist. It usually happens when I select an attachment from my desktop.

    I use the following code to select an attachment from file:

                var mailItem11 = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as MailItem;

               // mailItem11.Subject = "An attachment for you!";

                OpenFileDialog attachment = new OpenFileDialog();

                attachment.Title = "Select a file to send";

                if (attachment.FileName.Length > 0)


    Wednesday, December 9, 2015 9:05 PM


All replies

  • Does not sound like an exception thrown by Outlook. Which lien of your code raises that error?

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 9, 2015 11:03 PM
  • Thanks for the reply Dmitry. It wasn't one of them lines of code, I think it could be down to the way I handle files elsewhere. I can't post for now, but will keep you posted.
    Thursday, December 10, 2015 2:27 AM
  • Hi Darryl,

    I made an Outlook VSTO project with a button to call your code, it worked correctly to add attachments. I agree with you it could be down in other place. If you have any new information about this issue, please feel free to let us know. It would be helpful if you could share us the error line or the simple code to reproduce your issue.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 10, 2015 5:22 AM
  • Hello Darryl,

    The file name includes both the file path and the extension. If no files are selected, this method returns an empty string (""). What value does the FileName property returns? Did you try to debug the code?

    Thursday, December 10, 2015 6:28 PM