MboxStorageReader

Inheritance: java.lang.Object

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

public abstract class MboxStorageReader implements System.IDisposable, Closeable

Represents an MBOX file and provides methods for reading and extracting messages. The MBOX file format is used for storing a collection of email messages.

Example:


 // Create an instance of the MboxStorageReader using the factory method 'createReader'.
 MboxStorageReader mbox = MboxStorageReader.createReader("storage.mbox", new MboxLoadOptions());

 // Iterate through each message info object in the mbox storage.
 for (MboxMessageInfo mboxMessageInfo : mbox.enumerateMessageInfo()) {
     System.out.println("Subject: " + mboxMessageInfo.getSubject());
     System.out.println("From: " + mboxMessageInfo.getFrom());
     System.out.println("To: " + mboxMessageInfo.getTo());

     // Extract the full MIME message object from the MBOX storage using the message's unique entry ID.
     MailMessage eml = mbox.extractMessage(mboxMessageInfo.getEntryId(), new EmlLoadOptions());

     // Save the extracted MIME message as an .eml file.
     eml.save(eml.getSubject() + ".eml");
 }
 

Methods

MethodDescription
cancel()This method is used to interrupt a split operation if splitInto is running asynchronously.
close()
createReader(System.IO.Stream stream, MboxLoadOptions options)Creates the instance of reader.
createReader(InputStream stream, MboxLoadOptions options)Creates the instance of reader.
createReader(String fileName, MboxLoadOptions options)Creates the instance of reader.
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
enumerateMessageInfo()Exposes the enumerator, which supports an iteration of messages in storage.
enumerateMessages()Exposes the enumerator, which supports an iteration of messages in storage.
enumerateMessages(EmlLoadOptions options)Exposes the enumerator, which supports an iteration of messages in storage.
equals(Object arg0)
extractMessage(String id, EmlLoadOptions options)Get the message from MBOX.
getClass()
getCurrentDataSize()Gets the number of bytes that is read by ReadNextMessage method.
getEmlCopiedEventHandler()Event that occurs after successful copy of a MailMessage object within the #splitInto(long,String).splitInto(long,String) method.
getEmlCopyingEventHandler()Event that occurs before the MailMessage object copy process, within the #splitInto(long,String).splitInto(long,String) method.
getMboxFileCreatedEventHandler()Event that occurs when a new MBOX file is created during the #splitInto(long,String).splitInto(long,String) method.
getMboxFileFilledEventHandler()Event that occurs after filling an MBOX file with data within the #splitInto(long,String).splitInto(long,String) method.
getTotalItemsCount()Returns the number of messages in a storage.
hashCode()
nextMessage()Gets the next message info.
notify()
notifyAll()
readNextMessage()Reads the next message from underlying storage stream.
readNextMessage(EmlLoadOptions options)Reads the next message from underlying storage stream.
readNextMessage(String[] fromMarker)Reads the next message from underlying storage stream.
readNextMessage(String[] fromMarker, EmlLoadOptions options)Reads the next message from underlying storage stream.
setEmlCopiedEventHandler(MimeItemCopyEventHandler value)Event that occurs after successful copy of a MailMessage object within the #splitInto(long,String).splitInto(long,String) method.
setEmlCopyingEventHandler(MimeItemCopyEventHandler value)Event that occurs before the MailMessage object copy process, within the #splitInto(long,String).splitInto(long,String) method.
setMboxFileCreatedEventHandler(NewStorageEventHandler value)Event that occurs when a new MBOX file is created during the #splitInto(long,String).splitInto(long,String) method.
setMboxFileFilledEventHandler(NewStorageEventHandler value)Event that occurs after filling an MBOX file with data within the #splitInto(long,String).splitInto(long,String) method.
splitInto(long chunkSize, String outputPath)Splits the mbox storage into less sized parts.
splitInto(long chunkSize, String outputPath, String partFileNamePrefix)Splits the mbox storage into less sized parts.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

cancel()

public final void cancel()

This method is used to interrupt a split operation if splitInto is running asynchronously.

close()

public void close()

createReader(System.IO.Stream stream, MboxLoadOptions options)

public static MboxStorageReader createReader(System.IO.Stream stream, MboxLoadOptions options)

Creates the instance of reader.

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.StreamThe stream.
optionsMboxLoadOptionsadditional options when loading a Mbox storageMboxLoadOptions.

Returns: MboxStorageReader -

createReader(InputStream stream, MboxLoadOptions options)

public static MboxStorageReader createReader(InputStream stream, MboxLoadOptions options)

Creates the instance of reader.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe stream.
optionsMboxLoadOptionsadditional options when loading a Mbox storageMboxLoadOptions.

Returns: MboxStorageReader -

createReader(String fileName, MboxLoadOptions options)

public static MboxStorageReader createReader(String fileName, MboxLoadOptions options)

Creates the instance of reader.

Parameters:

ParameterTypeDescription
fileNamejava.lang.String
optionsMboxLoadOptionsadditional options when loading a Mbox storageMboxLoadOptions.

Returns: MboxStorageReader -

dispose()

public final void dispose()

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

enumerateMessageInfo()

public final System.Collections.Generic.IGenericEnumerable<MboxMessageInfo> enumerateMessageInfo()

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

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

enumerateMessages()

public final System.Collections.Generic.IGenericEnumerable<MailMessage> enumerateMessages()

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

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

enumerateMessages(EmlLoadOptions options)

public final System.Collections.Generic.IGenericEnumerable<MailMessage> enumerateMessages(EmlLoadOptions options)

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

Parameters:

ParameterTypeDescription
optionsEmlLoadOptionsSpecifies EmlLoadOptions when reading message from Mbox storage.

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

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

extractMessage(String id, EmlLoadOptions options)

public final MailMessage extractMessage(String id, EmlLoadOptions options)

Get the message from MBOX.

Parameters:

ParameterTypeDescription
idjava.lang.StringString representation of EntryId.
optionsEmlLoadOptionsSpecifies EmlLoadOptions when reading message from Mbox storage.

Returns: MailMessage - A MailMessage object.

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCurrentDataSize()

public final long getCurrentDataSize()

Gets the number of bytes that is read by ReadNextMessage method.

Returns: long

getEmlCopiedEventHandler()

public final MimeItemCopyEventHandler getEmlCopiedEventHandler()

Event that occurs after successful copy of a MailMessage object within the #splitInto(long,String).splitInto(long,String) method.

Returns: MimeItemCopyEventHandler

getEmlCopyingEventHandler()

public final MimeItemCopyEventHandler getEmlCopyingEventHandler()

Event that occurs before the MailMessage object copy process, within the #splitInto(long,String).splitInto(long,String) method.

Returns: MimeItemCopyEventHandler

getMboxFileCreatedEventHandler()

public final NewStorageEventHandler getMboxFileCreatedEventHandler()

Event that occurs when a new MBOX file is created during the #splitInto(long,String).splitInto(long,String) method.

Returns: NewStorageEventHandler

getMboxFileFilledEventHandler()

public final NewStorageEventHandler getMboxFileFilledEventHandler()

Event that occurs after filling an MBOX file with data within the #splitInto(long,String).splitInto(long,String) method.

Returns: NewStorageEventHandler

getTotalItemsCount()

public abstract int getTotalItemsCount()

Returns the number of messages in a storage.

Returns: int - Returns the number of messages in a storage.

hashCode()

public native int hashCode()

Returns: int

nextMessage()

public abstract MboxMessageInfo nextMessage()

Gets the next message info.

Returns: MboxMessageInfo - A MboxMessageInfo object if it can be read or null if no more messages are available.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

readNextMessage()

public abstract MailMessage readNextMessage()

Reads the next message from underlying storage stream.

Returns: MailMessage - A MailMessage object if it can be read or null if no more messages are available.

readNextMessage(EmlLoadOptions options)

public abstract MailMessage readNextMessage(EmlLoadOptions options)

Reads the next message from underlying storage stream.

Parameters:

ParameterTypeDescription
optionsEmlLoadOptionsSpecifies EmlLoadOptions when reading message from Mbox storage.

Returns: MailMessage - A MailMessage object if it can be read or null if no more messages are available.

readNextMessage(String[] fromMarker)

public abstract MailMessage readNextMessage(String[] fromMarker)

Reads the next message from underlying storage stream.

Parameters:

ParameterTypeDescription
fromMarkerjava.lang.String[]Gets the From Marker while parsing the MBox Storage file.

Returns: MailMessage - A MailMessage object if it can be read or null if no more messages are available.

readNextMessage(String[] fromMarker, EmlLoadOptions options)

public abstract MailMessage readNextMessage(String[] fromMarker, EmlLoadOptions options)

Reads the next message from underlying storage stream.

Parameters:

ParameterTypeDescription
fromMarkerjava.lang.String[]Gets the From Marker while parsing the MBox Storage file.
optionsEmlLoadOptionsSpecifies EmlLoadOptions when reading message from Mbox storage.

Returns: MailMessage - A MailMessage object if it can be read or null if no more messages are available.

setEmlCopiedEventHandler(MimeItemCopyEventHandler value)

public final void setEmlCopiedEventHandler(MimeItemCopyEventHandler value)

Event that occurs after successful copy of a MailMessage object within the #splitInto(long,String).splitInto(long,String) method.

Parameters:

ParameterTypeDescription
valueMimeItemCopyEventHandler

setEmlCopyingEventHandler(MimeItemCopyEventHandler value)

public final void setEmlCopyingEventHandler(MimeItemCopyEventHandler value)

Event that occurs before the MailMessage object copy process, within the #splitInto(long,String).splitInto(long,String) method.

Parameters:

ParameterTypeDescription
valueMimeItemCopyEventHandler

setMboxFileCreatedEventHandler(NewStorageEventHandler value)

public final void setMboxFileCreatedEventHandler(NewStorageEventHandler value)

Event that occurs when a new MBOX file is created during the #splitInto(long,String).splitInto(long,String) method.

Parameters:

ParameterTypeDescription
valueNewStorageEventHandler

setMboxFileFilledEventHandler(NewStorageEventHandler value)

public final void setMboxFileFilledEventHandler(NewStorageEventHandler value)

Event that occurs after filling an MBOX file with data within the #splitInto(long,String).splitInto(long,String) method.

Parameters:

ParameterTypeDescription
valueNewStorageEventHandler

splitInto(long chunkSize, String outputPath)

public final void splitInto(long chunkSize, String outputPath)

Splits the mbox storage into less sized parts.

Parameters:

ParameterTypeDescription
chunkSizelongThe approximate size of a chunk in bytes.
outputPathjava.lang.StringThe folder path where chunks will be created.

splitInto(long chunkSize, String outputPath, String partFileNamePrefix)

public final void splitInto(long chunkSize, String outputPath, String partFileNamePrefix)

Splits the mbox storage into less sized parts.

Parameters:

ParameterTypeDescription
chunkSizelongThe approximate size of a chunk in bytes.
outputPathjava.lang.StringThe folder path where chunks will be created.
partFileNamePrefixjava.lang.String

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