Email Message Files

How to Work With Email Message Files via Aspose.Email Cloud API

Aspose.Email Cloud API supports email message files with EML, MSG, MHTML and HTML format. We have API for creating, editing, converting such files. Also, email message files can be used in the built-in email client.

Our SDKs support two different ways of operating with email message files using MapiMessageDto and EmailDto. This tutorial shows how to use an EmailDto.

Email Message Files

Simply put, email message files are the files using to exchanging messages between people using electronic devices. Sounds simple, isn’t it?

You may already know this. In our time, it’s hard to find a person who doesn’t use email message. We use emails everywhere at our work, in a friendly conversation, etc.

There are many ways to send and retrieve emails, so, there are many file formats for these purposes.

Let’s find out which email formats exist:

  • EML — using in Microsoft Outlook Express as well as some other email programs. An email message saved to a file in the MIME RFC 822 standard format. EML files usually contain plain ASCII text for the main message body, headers and hyperlinks and attachments.
  • MSG — using in Microsoft Outlook and Exchange. An MSG file can contain plain ASCII text as in EML files.
  • HTML — the extension for web pages created for display in browsers. The HTML file format is very convenient to display emails on the web sites. 

As we have mentioned before, email message files are using for exchanging messages. With Aspose.Email Cloud API you can easily change the email’s data, attachments and other information. The API can help you to simplify the development of your product and achieve your goals. The Cloud approach provides you with the processing power of our servers, using them you do not need to process messages on your servers, provide this to us. User-friendly API provides security and ease of development.

How to Create Email Object and Save It as File on Storage

The best way to work with emails is to use EmailDto objects. EmailDto object contains all email’s data:

Create Email File — EmailDto Object

First, let’s create an EmailDto object and save it as a file on the Storage.

To create an email file (EML, MSG, MHTML, HTML) you need to create EmailDto object. To initialize EmailDto object let’s define main fields: From (accepts MailAddress object which contains the email address of a sender), To (accepts List of MailAddress objects; parameter To can contain several email addresses), Subject (accepts a string with a subject of an email), Body (accepts a string with a body’s content).

After creating EmailDto object we save it to Storage. To save it we need to choose storage and folder where we want to save our created email file. Also, we need to create a name for this email file. EmailApi class has a function called SaveAsync which requires one parameter — EmailSaveRequest

EmailSaveRequest has 3 fields:

Look at the following code examples:

How to create an EmailDto object and save it as a file on storage?