EML to MSG

An EML file stores an email message in the MIME RFC 822 format and is supported by Outlook, Outlook Express, Windows Live Mail, and Thunderbird. It is a plain‑text MIME (rfc822) file. In contrast, MSG is a Microsoft Outlook MAPI‑based compound binary format used for a single message object such as an email, appointment, contact, or task.

In this article we explain how to programmatically convert EML files to MSG format using the Aspose.Email Cloud REST API.

Email Processing API

Aspose.Email Cloud is a REST‑based service that creates, manipulates, and renders common email formats (Outlook EML, MSG, iCalendar files, and VCard) into other supported file formats. It lets you work with headers, sender addresses, message content, and attachments such as files, photos, or documents. You can also process contact cards (Operate VCard) and calendar items via iCalendar Support in your applications.

To simplify development, Aspose provides SDK wrappers for the Cloud APIs. For installation details, see the guide on how to install Aspose.Cloud SDKs.

Convert EML to MSG in C#

Follow these steps to perform the conversion:

  1. Create an EmailCloud object using your Client ID and Client Secret.
  2. Open the source EML file with File.OpenRead and upload it to cloud storage via UploadFile(…).
  3. Build an EmailGetAsFileRequest specifying the input file name and the target format (Msg).
  4. Call the EmailGetAsFile API to convert the stored EML file to MSG.
  5. Save the resulting file locally with File.Create.

You can download the sample files used in the example from sample.eml and converted.msg.

To convert a local file without uploading it first, use the EmailConvert API.

EML to MSG using cURL Command

Because Aspose.Email Cloud follows a REST architecture, you can invoke it directly with cURL. First, generate a JWT access token using the client credentials on the Aspose.Cloud dashboard. For details, see How to Obtain JWT token using a Client ID and Client Secret key.

With the JWT token, run the following command to convert an EML file stored in cloud storage to MSG and download the result:

curl -X GET "https://api.aspose.cloud/v4.0/email/as-file?fileName=sample.eml&format=Msg" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>" \
-o Converted.msg

Conclusion

This article demonstrated how Aspose.Email Cloud enables conversion of EML files to MSG using both C#/.NET and a simple cURL command. The Cloud SDKs are released under the MIT license, and the full source code is available on GitHub.

You can also explore the API via the interactive swagger view or reach out through the free customer support forum for any questions.