question

DanHenderson-7646 avatar image
0 Votes"
DanHenderson-7646 asked 41136686 commented

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

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!

office-vsto-com-dev
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please ignore this question ... I was being dumb.

0 Votes 0 ·

I I would like to know how you were being stupid since I have a very similar problem and am probably being stupid the same way!

0 Votes 0 ·

here are the steps I took:
1. add the microsoft outlook 16 com library.
2. add the "using Outlook = Microsoft.Office.Interop.Outlook;" statement at top of class file.
3. use like this: Outlook.Application oApp = new Outlook.Application();

now the stupid part was the fact that I forgot step 2!! Hate to admit it, but I was having a brain cramp.

0 Votes 0 ·

Hi Dan, Thanks for your response. Unfortunately, that is not my problem.
I would appreciate it if you would tell me the Path to the reference you are using. I am using
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Office.Interop.Outlook\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Outlook.dll
which is what I get when I added the COM tab entry for Microsoft.Office.Interop.Outlook
I have tried this with Embed Interop Types both True and False. I have also tried this in both VS2010 and VS2019. I suspect that I just do not have the proper .dll for my environment.
Thanks, Jim

0 Votes 0 ·
Show more comments

0 Answers