使用pypff/libpff导出PST和OST [英] Export PST and OST with pypff / libpff

查看:228
本文介绍了使用pypff/libpff导出PST和OST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to do in python a module to export PST and OST files and I am trying to use pypff to do so. Can someone give me some tips how can I use pypff to extract messages and attachments.

推荐答案

要在python中读取pst或ost文件中的消息,请参考

To read messages in pst or ost files, in python, refer to the following functions in https://github.com/PacktPublishing/Learning-Python-for-Forensics/blob/master/Chapter%2010/pst_indexer.py

folderTraverse(base)
checkForMessages(folder)
processMessage(message)

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

To read the attachments also, you could modify 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
    }

这篇关于使用pypff/libpff导出PST和OST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆