DOCX JPG PDF XML MHTML
  Product Family
OST

MHTML to OST Converter for Java Applications

Intuitive Java API to convert email files between formats. MHTML to OST conversion code sample and its integration with Java projects.

Convert MHTML to OST using Java API

Aspose.Email for Java provides an efficient and reliable solution for converting email files between various formats. It simplifies the process of email format conversion by providing a straightforward and efficient API. Try the concise and straightforward code sample that demonstrates the ease and efficiency of the email format conversion process. The code represents classes and methods for creating objects and manipulating them enabling developers to handle email data with ease and precision and achieve reliable and accurate results.

With the Java API, you don’t have to worry about complex algorithms or tedious manual work, saving time and effort for more important tasks to take your email processing applications to the next level.

How to Install Aspose.Email for Java Library

To start utilizing the capabilities of the powerful and feature-rich Java API is easy with one of the following actions:

  • download its latest version from Maven

  • install it within your Maven-based project by adding the following configurations to the pom.xml.

<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-email</artifactId>
<version>version of aspose-email API</version>
<classifier>jdk17</classifier>
</dependency>

In case of difficulties or questions regarding the installation process of the API, please visit the Installation section of our documentation .

How to Convert MHTML Files to OST Format

OST files are offline data files that allow users to work with their Outlook data even when they are not connected to the internet. By converting MHTML files to OST format, users can store and access their emails, contacts, calendars, and other data in a single, convenient file format that is compatible with Outlook.

Aspose.Email for Java is a powerful API that provides comprehensive functionality for working with email messages, contacts, calendars, and tasks in Java applications. To convert MHTML files to OST format, the library offers a PersonalStorage class that allows the program to open and work with Outlook Offline Storage Table (OST) files. The MapiMessage class representing an Outlook Message format document to be parsed and allowing for the access to various properties of an email message such as subject, sender, recipients, attachments, body content, and more. Additionally, the MhtmlLoadOptions class which is used to provide options for loading MHTML files. And the FolderInfo class representing the information about personal folders in a mail storage and allowing the user to create, delete, rename, and retrieve folders within a mail storage, as well as perform various operations on the messages stored in these folders. In the code snippet below, these classes work together to load an MHTML file as an email message and add it to the Inbox folder of the OST file. For more information about the API high code features, please visit our reference resources .

Steps to Convert MHTML to OST via Java

Java programmers can easily convert MHTML file to OST in just a few lines of code.

  1. Open the OST file by creating a PersonalStorage object using the fromFile() method and specifying the OST file path as a parameter.
  2. Load an existing MHTML file using the MailMessage.load() method and specify the file path as a parameter along with new MhtmlLoadOptions to load the MHTML file.
  3. Get the Inbox folder within the OST file by accessing the root folder of the PersonalStorage object and using the getSubFolder() method to retrieve the “Inbox” folder.
  4. Add the loaded MAPI message to the Inbox folder in the OST file by calling the addMessage() method on the FolderInfo object representing the Inbox folder and passing the MapiMessage object as a parameter.

System Requirements

Before running the Java conversion code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Get latest version of Aspose.Email for Java directly from Maven .
 

Convert MHTML to OST - Java

// Open the OST file
PersonalStorage ost = PersonalStorage.fromFile(ostFilePath);
// Load the MHTML file
MapiMessage msg = MapiMessage.load(mhtmlFilePath, new MhtmlLoadOptions());
// Get the Inbox folder in the OST file
FolderInfo folderInfo = ost.getRootFolder().getSubFolder("Inbox");
// Add the EML message to the Inbox folder
folderInfo.addMessage(msg);
 

What is MHTML File Format?

The MHTML (MIME HTML) file format is a standard for archiving and saving web pages or email messages as a single file. It combines HTML content and resources such as images, stylesheets, and scripts into a self-contained document, making it easier to share and preserve the original layout and appearance of the content. MHTML files are often used for offline viewing, archiving, or sharing web pages or emails with all their components intact.

What is OST File Format?

OST (Offline Storage Table) file format is a file that stores a copy of mailbox items from an Exchange server, allowing users to access their mailbox data even when they are offline. OST files are synchronized with the Exchange server when a connection is established, ensuring that any changes made offline are updated on the server as well. OST files are used by Microsoft Outlook for email, contacts, calendars, tasks, and other mailbox items in an Exchange environment.

File Format Conversions supported by Aspose.Email for Java

Aspose.Email for Java offers an extensive set of file format conversions designed to seamlessly handle emails, contacts, calendars, attachments. It empowers developers to effortlessly manipulate and transform data to meet the diverse needs of their applications. Implementing file format conversions in email applications facilitates their interoperability and elevates efficiency. Overall, the library supports conversion from EML , EMLX , ICS , MBOX , MHTML , MSG , OFT , OLM , OST , PST , VCF to other formats elevating user experience.
  • MHTML to OST Conversion Live Demos

    Other Supported Conversions

    You can also convert MHTML into many other file formats including few listed below.

    MHTML TO EML (Outlook Email Messages)
    MHTML TO EMLX (Apple EMLX Format)
    MHTML TO HTML (Hyper Text Markup Language)
    MHTML TO ICS (iCalendar)
    MHTML TO MBOX (Electronic Mail Messages)
    MHTML TO MSG (Outlook & Exchange Format)
    MHTML TO OFT (Outlook Email Templates)
    MHTML TO PST (Outlook Personal Storage Files)
    MHTML TO VCF (Virtual Card Format)