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.
YugJMallik
Member
91 Points
72 Posts
Creating .MSG file in C# without outlook installed
Apr 30, 2012 05:36 AM|LINK
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!!
Yug
www.extreme-minds.com
Mikesdotnett...
All-Star
154901 Points
19864 Posts
Moderator
MVP
Re: Creating .MSG file in C# without outlook installed
Apr 30, 2012 12:57 PM|LINK
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.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
wpf8
Member
2 Points
1 Post
Re: Creating .MSG file in C# without outlook installed
Feb 21, 2013 12:21 PM|LINK
Giva a try MSG .NET . The API works really good and does not require Outlook.