OlmStorage

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable, java.io.Closeable

public class OlmStorage implements System.IDisposable, Closeable

Represents an Outlook for Mac (.OLM) storage file and provides functionality to access and manipulate the data within the file such as emails, contacts, calendars, tasks, and notes.

The OlmStorage class allows users to read from and interact with the contents of .OLM files typically used by Microsoft Outlook for Mac. This class handles the various data types stored within an .OLM file by providing methods to enumerate and extract information.

Example:


 try (OlmStorage olm = OlmStorage.fromFile("storage.olm")) {
     // Retrieve the total number of items in the OLM storage.
     int totalItemsCount = olm.getTotalItemsCount();
     System.out.println("Total items count: " + totalItemsCount);

     // Iterate through each folder in the OLM storage.
     for (OlmFolder olmFolder : olm.getFolders()) {
         // Print the name of the currently iterated folder and the count of messages it contains.
         System.out.println("Folder: " + olmFolder.getName());
         System.out.println("Total items: " + olmFolder.getMessageCount());

         // Iterate through each message in the current folder.
         for (OlmMessageInfo messageInfo : olmFolder.enumerateMessages()) {
             // Print the subject of the current message to the console.
             System.out.println("Subject: " + messageInfo.getSubject());

             // Extract the full message object from the OLM storage.
             MapiMessage msg = olm.extractMapiMessage(messageInfo);

             // Save the extracted message as a .msg file.
             msg.save(msg.getSubject() + ".msg");
         }
     }
 } catch (Exception e) {
     e.printStackTrace();
 }
 

Constructors

ConstructorDescription
OlmStorage(TraversalExceptionsCallback callback)Initializes a new instance of the OlmStorage class.
OlmStorage(String fileName)Initializes a new instance of the OlmStorage class.
OlmStorage(InputStream stream)Initializes a new instance of the OlmStorage class.

Methods

MethodDescription
close()
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
enumerateMessages(OlmFolder folder)Exposes the enumerator, which supports an iteration of messages in folder.
equals(Object arg0)
extractMapiMessage(OlmMessageInfo messageInfo)Get the message from OLM storage.
extractMapiMessage(String id)Get the message from OLM.
fromFile(String fileName)Load OLM storage from file.
fromStream(InputStream stream)Load OLM from stream.
getCategories()Gets the supported item categories.
getClass()
getFolder(String name, boolean ignoreCase)Gets the folder by name.
getFolderHierarchy()Gets the folder hierarchy.
getFolders()Gets collection of folders.
getTotalItemsCount()Gets the total items count.
hashCode()
load(InputStream stream)Load OLM storage from stream.
load(String fileName)Load OLM storage from file.
notify()
notifyAll()
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

OlmStorage(TraversalExceptionsCallback callback)

public OlmStorage(TraversalExceptionsCallback callback)

Initializes a new instance of the OlmStorage class. Allows setting a callback method for handling exceptions that occur during OLM storage traversal.

Parameters:

ParameterTypeDescription
callbackTraversalExceptionsCallbackThe exception callback.

OlmStorage(String fileName)

public OlmStorage(String fileName)

Initializes a new instance of the OlmStorage class.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringOLM file name.

OlmStorage(InputStream stream)

public OlmStorage(InputStream stream)

Initializes a new instance of the OlmStorage class.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamSource stream java.io.InputStream with OLM storage data.

close()

public void close()

dispose()

public final void dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

enumerateMessages(OlmFolder folder)

public final System.Collections.Generic.IGenericEnumerable<MapiMessage> enumerateMessages(OlmFolder folder)

Exposes the enumerator, which supports an iteration of messages in folder.

Parameters:

ParameterTypeDescription
folderOlmFolderOlmFolder that represents information about folder in OLM storage.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.email.MapiMessage> - System.Collections.Generic.IEnumerableltTgt , that represents an enumerator that iterates through a messages in folder.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

extractMapiMessage(OlmMessageInfo messageInfo)

public final MapiMessage extractMapiMessage(OlmMessageInfo messageInfo)

Get the message from OLM storage.

Parameters:

ParameterTypeDescription
messageInfoOlmMessageInfoAn OlmMessageInfo object that represents information about message.

Returns: MapiMessage - A MapiMessage object.

extractMapiMessage(String id)

public final MapiMessage extractMapiMessage(String id)

Get the message from OLM.

Parameters:

ParameterTypeDescription
idjava.lang.StringString representation of EntryId.

Returns: MapiMessage - A MapiMessage object.

fromFile(String fileName)

public static OlmStorage fromFile(String fileName)

Load OLM storage from file.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringName of .olm file.

Returns: OlmStorage - An OlmStorage object that represents the current OLM file.

fromStream(InputStream stream)

public static OlmStorage fromStream(InputStream stream)

Load OLM from stream.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe System.IO.Stream.

Returns: OlmStorage - An OlmStorage object that represents the current OLM storage.

getCategories()

public final List<OlmItemCategory> getCategories()

Gets the supported item categories.

Returns: java.util.List<com.aspose.email.OlmItemCategory> - A list of OlmItemCategory objects.

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getFolder(String name, boolean ignoreCase)

public final OlmFolder getFolder(String name, boolean ignoreCase)

Gets the folder by name.

Parameters:

ParameterTypeDescription
namejava.lang.StringName of folder.
ignoreCasebooleanA value that indicates whether the name to match is case insensitive.

Returns: OlmFolder - An OlmFolder object.

getFolderHierarchy()

public final List<OlmFolder> getFolderHierarchy()

Gets the folder hierarchy.

Value: The folder hierarchy.

Returns: java.util.List<com.aspose.email.OlmFolder>

getFolders()

public final List<OlmFolder> getFolders()

Gets collection of folders.

Returns: java.util.List<com.aspose.email.OlmFolder> - The collection of folders that belong to the storage, i.e. the sub-folders of the current OLMStorage object.

getTotalItemsCount()

public final int getTotalItemsCount()

Gets the total items count. Returns the total number of message items contained in the OLM.

Returns: int - Total message items count.

hashCode()

public native int hashCode()

Returns: int

load(InputStream stream)

public final boolean load(InputStream stream)

Load OLM storage from stream. This method is used when a OlmStorage object is created using constructor with the TraversalExceptionsCallback parameter.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe stream.

Returns: boolean - ’true’ if the file has been loaded successfully and further traversal is possible; otherwise, false.

load(String fileName)

public final boolean load(String fileName)

Load OLM storage from file. This method is used when a OlmStorage object is created using constructor with the TraversalExceptionsCallback parameter.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe file name.

Returns: boolean - ’true’ if the file has been loaded successfully and further traversal is possible; otherwise, false.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int