使用pypff / libpff导出PST和OST

时间:2018-10-26 16:01:05

标签: python-3.x pst pffile

我需要在python中执行一个模块来导出PST和OST文件,而我正在尝试使用pypff来做到这一点。 有人可以给我一些提示,如何使用pypff提取消息和附件。

1 个答案:

答案 0 :(得分:1)

要在python中读取pst或ost文件中的消息,请参考https://github.com/PacktPublishing/Learning-Python-for-Forensics/blob/master/Chapter%2010/pst_indexer.py中的以下函数

folderTraverse(base)
checkForMessages(文件夹)
processMessage(message)

要阅读附件,您可以修改 processMessage(message)

def processMessage(message, folder):
    attachments = []
    total_attachment_size_bytes = 0
    if message.number_of_attachments > 0:
        for i in range(message.number_of_attachments):
            total_attachment_size_bytes = total_attachment_size_bytes + (message.get_attachment(i)).get_size()
            # get the content of the attachment file
            attachments.append(((message.get_attachment(i)).read_buffer((message.get_attachment(i)).get_size())).decode('ascii', errors="ignore"))
    return {
        "subject": message.subject,
        "sender": message.sender_name,
        "header": message.transport_headers,
        "body": message.plain_text_body,
        "creation_time": message.creation_time,
        "submit_time": message.client_submit_time,
        "delivery_time": message.delivery_time,
        "attachment_count": message.number_of_attachments,
        "total_attachment_size": total_attachment_size_bytes,
        "attachments": attachments
    }