libyal / libpff

Library and tools to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format
GNU Lesser General Public License v3.0
289 stars 74 forks source link

pypff: how do I read attachment data? #127

Closed mhechthz closed 6 months ago

mhechthz commented 6 months ago

I do this:

attachments = message.attachments            
if attachments:
    for attachment in attachments:
        attachment_data = attachment.read_buffer()
        ...

than I get an exception:

pypff_attachment_read_buffer: invalid argument read size value less than zero.

If there are no attachements I get Exception:

pypff_message_get_attachments: unable to retrieve number of attachments. libpff_local_descriptors_node_get_entry_data: invalid local descriptors node. libpff_local_descriptors_get_value_by_identifier: unable to retrieve node entry: 0 data. libpff_local_descriptors_tree_get_value_by_identifier: unable to retrieve index value: 1649 from index. libpff_table_get_local_descriptors_value_by_identifier: unable to retrieve local descriptor identifier: 1649. libpff_item_values_get_local_descriptors_value_by_identifier: unable to retrieve local descriptor identifier: 1649. libpff_message_determine_attachments: unable to retrieve local descriptor identifier: 1649. libpff_message_get_number_of_attachments: unable to determine attachments.

which is not nice but can be catched.

What can I do to properly get the attachements?

mhechthz commented 6 months ago

ok, found out that i need to specify the size by:

size = attachment.get_size()
attachment_data = attachment.read_buffer(size)

but how to get the name and the type of the attachement?