I have a HMEFMessage
and iterating all attachments using
for (Attachment tnefAttachment : hmef.getAttachments()) {
Attachment size can be obtained using tnefAttachment.getMAPIAttribute(MAPIProperty.ATTACH_SIZE)
. This method returns MAPIAttribute instance and it has only getData(), which returns byte[].
How can I convert byte[] from MAPIAttribute to Long (size)?
According to this - https://poi.apache.org/apidocs/org/apache/poi/hmef/attribute/package-summary.html - there is a MAPIStringAttribute.getAsString(attr), which does not work with ATTACH_SIZE.
EDIT - ATTACH_SIZE is Long according to http://grepcode.com/file/repo1.maven.org/maven2/org.openl.rules/org.openl.lib.poi.dev/5.9.4.1/org/apache/poi/hsmf/datatypes/MAPIProperty.java .
MAPIProperty.ATTACH_SIZE
only indicates the attribute you are requesting withgetMAPIAttribute()
so its type does not matter.I suggest using the size of the content to solve your problem:
will give you the size of the attachment in bytes.
If you want to convert a byte array to long, see this question.