How to Save Email Message to Disk in C#

In this step by step tutorial, we’ll explain how to save email message to disk in C#. The email message can be saved as EML or MSG file formats on the disk. We’ll be getting messages from Exchange email box, however you can get messages from other mail boxes as well and save to disk.

Steps to Save Email Message to Disk in C#

  1. Get Aspose.Email for .NET package from
  2. Include Aspose.Email.Clients.Exchange and Aspose.Email.Clients.Exchange.WebService namespaces
  3. Set license with the help of SetLicense method
  4. Provide Exchange Server account information
  5. Create an object of NetworkCredential class
  6. Create a new Exchange client object of EWSClient Class
  7. Loop through all the email messages read from the mail box
  8. Save each individual email message to EML or MSG file formats

By following the above simple steps, you can save email message to EML in C# code on the disk. In our previous topic, we explained how to send email in C# using Gmail SMTP server. However, in this topic, we’re using the Exchange server instead to fetch the emails and then save them to disk.

Code to Save Email Message to Disk in C#

In the above code, we’re saving email messages as .eml and .msg formats. Please note that in this code, we’re fetching all of the messages and saving them one by one in separate files. However, if your inbox has a lot of messages then you need to modify the approach accordingly.