How to fetch the size of a MapiMessage object in Java?

Hi All,

Use Case:

  1. We are using the below code to for reading emails within PST and getting a MapiMessage object. Below is the Java code.

PersonalStorage asposePstFile = PersonalStorage.fromFile(path_to_pst);
FolderInfo folderInfo = asposePstFile.getRootFolder();
FolderInfoCollection folderInfoCollection = folderInfo .getSubFolders(FolderKind.Normal);
for (FolderInfo childFolder : childFolders) {
MessageInfoCollection messageInfoCollection = folder.getContents();
for (MessageInfo messageInfo : messageInfoCollection) {
MapiMessage message = asposePstFile.extractMessage(messageInfo);
//QUERY - HERE NEED TO FETCH THE SIZE OF MAPIMESSAGE
}
}

  1. Once we have the MapiMessage object, how can we fetch the size of this MapiMessage Object. Is there any method supported for MapiMessage Object or what is the equivalent MapiMessage property to fetch the size. In PSTLIB api, its equivalent was message.getMessageSize()

Could you please help on this?

Thanks & Regards

Hello @anshulmehta,

There is PidTagMessageSize property in MAPI.

Please try the following:

long messageSize = msg.getProperties().get_Item(KnownPropertyList.MESSAGE_SIZE).getLong();

Thank you.