How to Export Emails From Microsoft 365 Outlook as EML Files

How to Export Emails From Microsoft 365 Outlook as EML Files

Whether for business or personal communication, Outlook stands as a foundational element in Microsoft 365 for effective correspondence and collaboration. Users and administrators often export emails to create offline copies and safeguard important messages. In this blog, we will explore the methods to export emails as EML files from Outlook in Microsoft 365.

What is EML Format in Outlook?

EML (Electronic Mail) is a standard file extension format supported by various email clients. This file format is widely used to store email messages for its versatility and compatibility. An EML file contains the complete content of an email, including text, attachments, and metadata.

Difference Between EML and PST Formats

You may wonder why we choose to export emails as EML files when we have the option to export Office 365 mailbox to PST. The preference to export emails from Office 365 to EML lies in the fact that EML is a highly advanced file extension designed to store individual emails. In contrast, the PST format encompasses all Outlook mailbox data, including various item types, folder structure, and settings. This makes EML files more suitable for a focused email export.

Reasons to Export Emails as EML

Here, we have listed a few major and important reasons why users and admins export emails as EML files:

  • Exporting mail as EML files can prevent the loss of data if the email is accidentally deleted.
  • As single email message files, EMLs are easily shareable and portable during any submission or investigation. The EML files can be accessed offline, and it also supports multiple desktop-based email clients.
  • During the M365 user offboarding, exporting some essential emails from the employee’s mailbox can be helpful for future reference.
  • If your organization has applied a retention policy that deletes emails at certain intervals, exporting important emails as EML can be useful for future use.

Export Emails From Outlook as EML Files

As a Microsoft 365 user or admin, you can save emails from Outlook in EML format using the following methods. While all three methods help users export their emails, the final method provides admins the capability to export any user emails.

How to Save an Email as an EML File in Outlook on the Web?

Outlook Web provides a straightforward method for exporting emails to EML. Follow these step-by-step instructions to seamlessly export your emails:

  1. First, log in to Outlook on the web.
  2. Once logged in, go to the respective folder of the mail.
  3. Choose the respective mail you want to export as EML from that specific folder.
  4. In the mail preview area, select the ellipses (…) and choose the Save as option.
  5. Finally, the email will be saved as an EML file in the respective download location.

Save an Email as an EML File in Outlook on Web -Export Emails as EMLNote: The procedure for exporting emails from the new Outlook client application is the same as the above approach to export emails from Outlook on the web.

How to Convert a Message to an EML File in Outlook Desktop Client?

Outlook Clients, the desktop version of Microsoft Outlook, offers a convenient and accessible way to export emails to EML format. Using the older Outlook app on your Windows operating system prohibits the direct export of emails as EML files. However, you have the flexibility to export them in formats such as MSG, TXT, HTML, and more.

The MSG file format is only supported by Microsoft Outlook, whereas the EML format is supported by multiple email clients such as Outlook Express, Thunderbird, Windows Live Mail. etc. If you initially save your email as an MSG file, you can later convert it to EML format using online converters or third-party tools.

Now, we are going to focus on the process of exporting emails as TXT and subsequently converting them to EML files. This approach eliminates the need for third-party tools or online converters. Here’s a general guide:

  1. Launch the old Outlook application on your computer.
  2. Navigate to the folder containing the emails you want to export and select the email.
    Export mailbox as an EML file - Outlook Client
  3. In the top menu, go to File and select Save As.
  4. In the Save As dialog box, select a location to save the files and choose Text Only (*.txt) from the Save as type drop-down menu.
  5. Click on the Save button to save the selected emails to the chosen location.
    Save As - Export Emails as EML
  6. After that, open the saved text file and save it in the EML file format.
    Save an email as EML in Outlook client app

How to Export Emails From Outlook Using PowerShell ?

Unlike the UI approach, PowerShell helps you to export multiple emails or entirely export the Exchange Online mailbox at a single execution. Before getting started to export emails from Outlook in Microsoft 365 using PowerShell, connect to the Microsoft Graph PowerShell using the scope “Mail.Read”.

Connect-MgGraph -Scopes Mail.Read 

Note: To export emails from other M365 user accounts as EML files with admin consent, ⁠connect to Graph PowerShell using certificate-based credentials through an Azure AD app with “Mail.Read” permission.

The process of exporting mail as EML files consists of two steps:

  1. Get Outlook mail messages
  2. Export Outlook emails

1. Get Outlook Mail Messages Using PowerShell

The first step for exporting emails from Outlook is selecting the required emails and assigning the selection to a variable. Here are various options for selecting email messages in Outlook based on specific needs. Select the emails with the “Get-MgUserMessage” cmdlet using any one of the following appropriate methods.

1. Select entire mailbox: To select the entire emails from a particular Exchange Online mailbox and store them in a variable, execute the following code snippet with the user’s UPN.

$mails = Get-MgUserMessage -UserId <User’sUPN> -All
$mails | Select-Object Subject, ReceivedDateTime

Select entire mailbox

2. Select emails between the specific dates: For selecting the emails between the specific dates, execute the following code. Replace the starting date, ending date, and user’s UPN in the cmdlet.

$mails = Get-MgUserMessage -UserId <User’s UPN> -All -Filter "ReceivedDateTime ge <YYYY-MM-DD> AND ReceivedDateTime le <YYYY-MM-DD>"
$mails | Select-Object Subject, ReceivedDateTime 

Select mails between the specific dates -Export Emails as EML

Note: To get only the emails received on a particular day, use the same date in two conditions.

3. Select emails based on subject: To select and export only the emails based on words or phrases present in the subject line, utilize the following code. Replace the user’s UPN and subject line keyword in the cmdlet.

$mails = Get-MgUserMessage -UserId <User’sUPN> -All -Filter "Contains(Subject, '<Word(s) in Subject Line>')"
$mails | Select-Object Subject, ReceivedDateTime

Select emails based on subject -Export Emails as EML

4. Select emails based on subject between specified dates: To select mails between the specific dates based on words present in the subject line, utilize the following code. Replace the user’s UPN, starting, ending date, and subject line keyword in the cmdlet.

$mails = Get-MgUserMessage -UserId <User’s UPN> -All -Filter "ReceivedDateTime ge <YYYY-MM-DD> AND ReceivedDateTime le <YYYY-MM-DD> AND Contains(Subject, '<Word(s) in Subject Line>')" 
$mails | Select-Object Subject, ReceivedDateTime

Select emails based on subject in specified dates

2. Export Outlook Emails Using PowerShell

After selecting the required emails and storing them in a variable, you can export those selected emails using the “Get-MgUserMessageContent” cmdlet. Replace the folder path with the path of the folder where the exported emails need to be saved and the user’s UPN with the UPN of the appropriate in the following PowerShell script.

ForEach ($mail in $mails) { 
    $filename = "$($mail.subject) $($mail.ReceivedDateTime).eml".Split([IO.Path]::GetInvalidFileNameChars()) -join '-' 
    $filepath = "<Folder Path>" + $filename 
    Try { 
        Get-MgUserMessageContent -UserId <User’s UPN>-MessageId $mail.id -OutFile $filepath -ErrorAction Stop 
    } 
    Catch { 
        Write-Host "Mail export failed:" $mail.Subject 
    } 
} 

Note: To export emails from on-premises Exchange, utilize the “Export-Message” cmdlet in Exchange Online PowerShell.

Overall, we hope that this comprehensive resource helps you to export emails as EML from Outlook. If you have any further questions, feel free to connect with us. Thank you for reading!

How to Export Emails From Microsoft 365 Outlook as EML Files

by Thiraviam time to read: 5 min
0