Экспорт PST и OST с pypff / libpff - PullRequest
0 голосов
/ 26 октября 2018

Мне нужно сделать в python модуль для экспорта файлов PST и OST, и я пытаюсь использовать pypff для этого.Может кто-нибудь дать мне несколько советов, как я могу использовать pypff для извлечения сообщений и вложений.

1 Ответ

0 голосов
/ 14 ноября 2018

Чтобы прочитать сообщения в pst или ost файлах, в python, обратитесь к следующим функциям в https://github.com/PacktPublishing/Learning-Python-for-Forensics/blob/master/Chapter%2010/pst_indexer.py

folderTraverse (основа)
checkForMessages (папка)
ProcessMessage (сообщение)

Чтобы также прочитать вложения, вы можете изменить processMessage (сообщение)

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
    }
...