Closed ztravis closed 6 years ago
hello @ztravis Can you explain a little bit what you did in this tweak ? i'm trying to get the attachments from the libpff message. it seems in the code that you removed part of the solution, and added it somewhere else.
Can you help ?
Basically, i'm trying to do that in python code :
def search_msg_content(msg, filename):
msg_subject=msg.get_subject().encode("UTF-8")
print msg_subject
msg_plaintext=msg.get_plain_text_body().encode("UTF-8")
print msg_plaintext
print "This message '%s' has %s attachments" % (msg_subject, msg.get_number_of_attachments())
for attachment in msg.get_attachments():
print attachment
Of course, it throws an exception : "'pypff.message' object has no attribute 'get_attachments'"
Thanks in advance,
It looks like you're calling msg.get_attachments()
, but no such method exists. You can iterate directly through msg.attachments
:
for attachment in msg.attachments:
print attachment
Or you can fetch individual attachments by index:
for i in range(msg.get_number_of_attachments()):
print msg.get_attachment(i)
This should work on the main branch of this repo (i.e. without my tweaks, which I didn't mean to PR here in the first place...).
(FYI on markdown - you can add code blocks with triple-backquotes: "```")
Thanks, i edited my question with the triple backquotes,
so, regarding what you are suggesting:
for the first one :
for attachment in msg.attachments:
print attachment
i get a : 'pypff.message' object has no attribute 'attachments' while trying file test.pst
and for the second one :
for i in range(msg.get_number_of_attachments()):
print msg.get_attachment(i)
i get a : 'pypff.message' object has no attribute 'get_attachment' while trying file test.pst
no more luck with get_attachment_by_index 'pypff.message' object has no attribute 'get_attachment_by_index' while trying file test.pst
So at the moment i don't see how to retreive the attachment. Can you help ?
What does 'i didn't mean to PR' stands for ? (sorry, i'm french :) )
Tweaks to libpff python bindings.