Tuesday, March 30, 2010

Create .EML or .MSG files programmatically using C#.

In this article I will try to document my experiences about creating the .eml and .msg files using C#.

Problem statement:

The requirement is to send emails to out side world with attachments. The email can contain more than one email as attachment and those attachments should look like as new email message is actually being attached to the outgoing email.

Possible soultions identified:

1. As we need to have email as attachment, so having other kinds of attachments ruled out.
2. Possible option for the email attachments are either .eml or .msg.

.MSG file can be created using Microsoft.Interop.xxx assembly and attach to the email and remember .msg is a Microsoft propriatory standard.

Courtesy : For more information: http://weblogs.asp.net/darrensim/archive/2008/06/29/creating-an-outlook-message-file-with-c.aspx



.eml is the global standard. But how can we create .eml file? This can be done by digging through the System.Net.mail.MailMessage.Send() method.
A very good article is available in codeproject : http://www.codeproject.com/kb/ip/smtpclientext.aspx?msg=2876295

2 comments:

  1. You can also create .EML or .MSG files in C#/VB.NET by using Aspose.Email for .NET and can also convert them to each other format and this API offers many more features.

    ReplyDelete
  2. PstViewer Pro has a command line operation for developers who want to run it from a command line or batch file. You can do lots of conversion of emails using this function. http://pstviewer.com

    ReplyDelete