0

I have Visual Studio 2012 professional edition, and i want to add a reference for "Microsoft Outlook 15.0 Object Library" inside my web project, but i can not find it inside the COM, here is a screen shot from my Visual Studio:-

enter image description here

so can anyone advice how i can add the "Microsoft Outlook 15.0 Object Library" to my visual studio 2012 ?

John John
  • 1
  • 72
  • 238
  • 501
  • 1
    Is Outlook installed on that machine? You should not be using Outlook in any web project. – Dmitry Streblechenko May 09 '18 at 16:48
  • @DmitryStreblechenko no outlook is not installed in the machine.. as the machine is a sharepoint server and i want to develop a custom solution for my sharepoint .. what i am trying to do is to edit the subject for an `.oft` file.. as described in this question which i wrote before https://stackoverflow.com/questions/50179260/can-i-copy-a-oft-file-and-change-its-subject – John John May 09 '18 at 17:52
  • @DmitryStreblechenko .. and to do so i need to add a reference to `Microsoft Outlook 15.0 Object Library` inside my web project – John John May 09 '18 at 18:30

2 Answers2

0

Well, if Outlook is not installed, how can you expect its type library to be present? You can of course create the interop dll on a machine where Outlook is installed, but your code still won't run without Outlook being present.

Worse than that, Outlook (just like any Office app) cannot run in a service (such as IIS). You can use Extended MAPI (C++ or Delphi) to edit the OFT files, but doing that in C# is far from trivial. And you will still need to install Outlook to have the Extended MAPI system present. In C#, you can try to use Redemption (I am its author) - it still requires the MAPI system, but unlike OOM, its RDO family of objects can be used in a service. In your case, you can call RDOSession.GetMessageFromMsgFile (it works with both MSG and OFT files), modify the Subject property of the returned RDOMail object, then call RDOMail.Save.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • thanks for the info ,, so you mean the answer i got on this question https://stackoverflow.com/questions/50179260/can-i-copy-a-oft-file-and-change-its-subject can not be done for a web application which is installed inside IIS? – John John May 09 '18 at 20:40
  • now i am trying to explore the RDOSession , but not sure if it will allow retrieving a .OFT file from a URL, then to paste it inside a destination URL, and then modify the subject on the destination folder?? – John John May 09 '18 at 22:15
  • Neither RDOSession.GetMessageFromMsgFile in Redemption nor Application.CreateItemFromTemplate in OOM would let you pass a url - they only expect file paths. It is your responsibility to retrieve the OFT file and upload it back after you are done. – Dmitry Streblechenko May 09 '18 at 23:03
0

how i can add the "Microsoft Outlook 15.0 Object Library" to my visual studio 2012

Looks like you just need to install Outlook first.

Anyway, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

As a workaround you may consider using a low-level API on which Outlook is based on - Extended MAPI. Or just use any third-party wrappers around that API.

If you deal only with Exchange account you may also consider using EWS or Outlook REST API, see EWS Managed API, EWS, and web services in Exchange for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45