Creating an Outlook Template File (.oft) in ASP.Net MVC

I have a requirement to load an html template as an OFT file in an ASP.Net MVC4 web application (using C #). I already tried Microsoft.Office.Interop.Outlook, which works fine on my local machine, but didn't work on the server. This requires that Outlook be installed on the server, and I also heard that it is not good practice to automate MS office applications on the server for a web application. Is it possible to create my own file without using MS Office Outlook? Are there any free libraries for this? ? Does anyone know a solution, please help.

+5
source share
1 answer

The OFT file is an MSG file with a different class GUID. The MSG file is an OLE Storage (IStorage) file.

Since the MSG file format is documented , you can create an MSG file with a CLSID {0006F046-0000-0000-C000-000000000046} instead of from {00020D0B-0000-0000-C000-000000000046}.

You can also use Redemption - its RDO family of objects can be used in the service, you just need to make sure that Outlook is installed with the appropriate bitness (Redemption uses the MAPI system installed by Outlook, and not the Outlook object model, which cannot be used in the service).

VB script:

set Session = CreateObject("Redemption.RDOSession") set Msg = Session.CreateMessageFromMsgFile("c:\Temp\TestMsg.msg") Msg.Body = "This is a test template" Msg.Subject = "Template" Msg.Save Msg.SaveAs "c:\Temp\TestTemplate.oft", olTemplate 

C # (from the top of the head):

  Redemption.RDOSession rSession = new Redemption.RDOSession(); Redemption.RDOMail Msg = rSession.CreateMessageFromMsgFile("c:\Temp\TestMsg.msg"); Msg.Body = "This is a test template"; Msg.Subject = "Template"; Msg.Save(); Msg.SaveAs("c:\Temp\TestTemplate.oft", Redemption.rdoSaveAsType.olTemplate); 
+1
source

Source: https://habr.com/ru/post/1240917/


All Articles