how to use the outlook interop with c# .net 5

Dan Henderson 31 Reputation points
2021-06-05T23:46:09.063+00:00

I created a class in .net 4.8 which works great. I decided to move this to .net 5 and use it in a wpf project, but I can't seem to add the dll successfully. I have added a COM reference to the project of Microsoft Outlook 16.0 Object Library (it has an identity of Interop.Microsoft.Office.Interop.Outlook).

When I try to add that to the using statement, the leading word Interop is flagged in red and tells me to add the using System.Windows.Interop;

OK, I did that and it looks like this:
using System.Windows.Interop;
using Outlook = Microsoft.Office.Interop.Outlook;

And it allows this line of code: Outlook.Application oApp = new Outlook.Application();

Problem now becomes oApp is not recognized to get a namespace, which I need to get a folder ... etc.

I would appreciate any guidance here on doing the correctly!

Microsoft 365 and Office | Development | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.