Search code examples
c#outlookoffice-interopemail-templatesoft

interop exception when trying to read the contents of an office outlook template


I am trying to read an office template (.oft file) with embedded images in the body of the email. I tried using the MsgReader nuget package which reads the contents, but cant manage the images in the body.

I have also tried using Microsoft.Office.Interop.Outlook, but this throws the following error at runtime :

Error: System.IO.FileNotFoundException: Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. The system cannot find the file specified. File name: 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

I am struggling to find a solution to this. On my work computer i have Office 365 installed. in the about tab is says Microsoft Outlook for Microsoft 365 MSO (16.0.12827.20200) 32-bit

So far based on what i have read, i have tried running my prototype project in IIS instead of IIS Express, but this did not resolve the problem. Do I need to install a specific version of Outlook, or some redistribution files? Or is there a better way to do this?


Solution

  • I was not able to get he interop to work, but found a working third party solution : https://downloads.aspose.com/email/net

    this nuget package will read the body content including images corretly without the need for using interop.