Share via


Creating .MSG file in C# without outlook installed

Question

Monday, April 30, 2012 1:36 AM

Hi,

I want to create a .msg file in C#. The below code works find when outlook is installed in the Machine and referring Microsoft.office.interop.outlook.dll. But failed in windows server, where outlook is not installed.

        Application outlookApp = new Application();
        MailItem mailitm = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);
        mailitm.Subject = "Test for MSG";
        mailitm.Body = "Sample Body";
        
        mailitm.SaveAs(@"D:\outlook\Test.msg", OlSaveAsType.olMSG);

        MailMessage msg = new MailMessage();

Is there anyway i can do it? May be without using outlook components or installing only .dll in the server.

Thanks!! 

All replies (2)

Monday, April 30, 2012 8:57 AM âś…Answered

You can't use Outlook interop unless Outlook is installed, as you have already discovered. Probably your only option is to use a third party component such as Aspose Email (although it isn't cheap): http://www.aspose.com/categories/.net-components/aspose.email-for-.net/default.aspx

Google might help you find a lower cost/free one.


Thursday, February 21, 2013 8:21 AM

Giva a try MSG .NET . The API works really good and does not require Outlook.