Pst to eml linux

TimRepke / README.md

This script extracts all emails from an Outlook PST archive and saves them into some output folder as individual RFC822 compliant *.eml files.

Installing the external dependency pypff may not be straight forward (it wasn’t for me). I forked the original repository to make it work in Python 3. If you get errors, check their wiki pages for help or try my fork. Below are the steps that worked for me:

cd libpff/ ./synclibs.sh ./autogen.sh ./configure --enable-python make sudo make install python setup.py build sudo python setup.py install

Now that everything is installed, you can execute the script as follows: python pst2eml.py /path/to/archive.pst /path/to/output/dir

Optionally, you can write the log into a file by adding —logfile=/path/to/log_dir to the command.

Full disclaimer: I was inspired by this script, but as you may see, I pretty much threw everything overboard and made my own thing. Only kept the logging and argparse really.

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

import os
import argparse
import logging
import re
import pypff
def process_folder ( folder , path ):
folder_path = path + ‘/’ + ( folder . name or ‘root’ )
n_msg = folder . number_of_sub_messages
logging . debug ( ‘Processing folder «<>» with <> sub-folders and <> messages; full path: «<>«‘ . format (
folder . name , folder . number_of_sub_folders , n_msg , folder_path ))
safe_path = re . sub ( r'[ /]’ , ‘_’ , re . sub ( r'[^a-z0-9 /]’ , » , folder_path . lower ()))
for mi , message in enumerate ( folder . sub_messages ):
logging . debug ( ‘<>/<> > Processing message by <> with subject: <>‘ . format ( mi , n_msg ,
message . sender_name , message . subject ))
msg = process_message ( message )
fname = os . path . join ( output_directory , safe_path + ‘_’ + str ( mi ) + ‘.eml’ )
logging . debug ( ‘ — saving as <>‘ . format ( fname ))
with open ( fname , ‘w’ ) as f :
f . write ( msg )
for sub_folder in folder . sub_folders :
process_folder ( sub_folder , folder_path )
def get_body ( msg ):
def prep ( b ):
if type ( b ) == bytes :
b = b . decode ( «utf-8» )
return b . strip () if b else None
body = prep ( msg . plain_text_body )
if body :
return ‘plain-text’ , body
body = prep ( msg . html_body )
if body :
return ‘html’ , body
body = prep ( msg . rtf_body )
if body :
return ‘rtf’ , body
return ‘plain-text’ , »
def process_message ( message ):
msg = »
keys = []
for hp in message . transport_headers . split ( ‘ \n ‘ ):
pts = re . findall ( r’^([^:]+): (.+)\r$’ , hp )
if pts :
key = pts [ 0 ][ 0 ]. capitalize ()
if key in keys :
key = ‘X-‘ + key
keys . append ( key )
val = pts [ 0 ][ 1 ]
if key == ‘Date’ :
val = ‘, ‘ . join ( val . split ( ‘,’ )[: 2 ])
msg += key + ‘: ‘ + val + ‘ \r \n ‘
msg += ‘X-Sender-Name: ‘ + message . sender_name + ‘ \r \n ‘
msg += ‘X-Delivery-Time: ‘ + str ( message . delivery_time ) + ‘ \r \n ‘
msg += ‘X-Creation-Time: ‘ + str ( message . creation_time ) + ‘ \r \n ‘
msg += ‘X-Client-Submit-Time: ‘ + str ( message . client_submit_time ) + ‘ \r \n ‘
msg += ‘X-Subject: ‘ + message . subject + ‘ \r \n ‘
msg += ‘X-Attachments: ‘ + str ( message . number_of_attachments ) + ‘ \r \n ‘
btype , body = get_body ( message )
msg += ‘X-Body-Type: ‘ + btype + ‘ \r \n ‘
msg += ‘ \r \n ‘
msg += body
return msg
if __name__ == «__main__» :
parser = argparse . ArgumentParser ()
parser . add_argument ( ‘PST_FILE’ , help = «PST File Format from Microsoft Outlook» )
parser . add_argument ( ‘OUTPUT_DIR’ , help = «Directory of output for temporary and report files.» )
parser . add_argument ( ‘—logfile’ , default = None , help = ‘File path of log file.’ )
args = parser . parse_args ()
output_directory = os . path . abspath ( args . OUTPUT_DIR )
if not os . path . exists ( output_directory ):
os . makedirs ( output_directory )
if args . logfile :
if not os . path . exists ( args . logfile ):
os . makedirs ( args . logfile )
log_path = os . path . join ( args . logfile , ‘pst_indexer.log’ )
else :
log_path = None
logging . basicConfig ( level = logging . DEBUG , filename = log_path ,
format = ‘%(asctime)s | %(levelname)s | %(message)s’ , filemode = ‘w’ )
logging . info ( ‘Starting Script. ‘ )
pst_file = args . PST_FILE
try :
pff_file = pypff . file ()
pff_file . open ( pst_file )
process_folder ( pff_file . root_folder , os . path . basename ( pst_file ))
except Exception as e :
raise
finally :
pff_file . close ()
logging . info ( ‘Script Complete’ )
 File "pst2eml.py", line 110, in process_folder(pff_file.root_folder, os.path.basename(pst_file)) File "pst2eml.py", line 27, in process_folder process_folder(sub_folder, folder_path) File "pst2eml.py", line 27, in process_folder process_folder(sub_folder, folder_path) File "pst2eml.py", line 20, in process_folder msg = process_message(message) File "pst2eml.py", line 75, in process_message btype, body = get_body(message) File "pst2eml.py", line 36, in get_body body = prep(msg.plain_text_body) File "pst2eml.py", line 34, in prep return b.strip() AttributeError: 'NoneType' object has no attribute 'strip' 

Источник

Читайте также:  Linux which windows manager

PST to EML Converter

Convert PST to EML online, from any device with a modern browser like Chrome and Firefox.

Convert your PST files online. You can convert your PST documents from any platform (Windows, Linux, macOS). No registration needed. Just drag and drop your PST file on upload form, choose the desired output format and click convert button. Once conversion completed you can download your EML file.

You even can perform more advanced conversions. For example you can convert password protected documents. Just expand LoadOptions and enter the password of your file. Or you can add a watermark to the converted EML file. Expand the ConvertOptions and fill the fields for watermarking.

Converted EML files are stored in the cloud. Privacy is 100% guaranteed. All documents are removed from the cloud after 24 hours.

You can convert your PST documents from anywhere, from any machine or even from a mobile device. The PST converter is always available online and is completely free.

  • Convert WORD to PDF, EXCEL to PDF, PDF to WORD, POWERPOINT to IMAGE, VSDX to PDF, HTML to DOCX, EPUB to PDF, RTF to DOCX, XPS to PDF, ODT to DOCX, ODP to PPTX and many more document formats
  • Simple way to instant convert PST to EML
  • Convert PST from anywhere — it works on all platforms including Windows, MacOS, Android and iOS

Free Document

Free Document Conversion, Viewer, Merger app for Windows

  • Easily convert, view or merge unlimited files on your own Windows PC.
  • Process Word, Excel, PowerPoint, PDF and more than 100 file formats.
  • No limit of file size.
  • Batch conversion of multiple files.
  • One app with rich features like Conversion, Viewer, Merger, Parser, Comparison, Signature
  • Regular FREE updates with new features coming every month
Читайте также:  Counter strike on linux ubuntu

PST Personal Storage File

Files with .PST extension represent Outlook Personal Storage Files (also called Personal Storage Table) that store variety of user information. User information is stored in folders of different types that include emails, calendar items, notes, contacts, and several other file formats. PST files are used for archiving emailing data offline that can be later loaded and viewed in various applications.

EML E-Mail Message File

EML file format represents email messages saved using Outlook and other relevant applications. Almost all emailing clients support this file format for its compliance with RFC-822 Internet Message Format Standard. Microsoft Outlook is default software for opening EML message types. EML files can be used for saving to disc as well as sending out to recipients using communication protocols.

How to convert PST to EML

  • Open our free PST to EML converter website.
  • Click inside the file drop area to upload PST file or drag & drop PST file.
  • Click on Convert button. Your PST files will be uploaded and converted to EML result format.
  • Download link of result files will be available instantly after conversion.
  • You can also send a link to the EML file to your email address.
  • Note that file will be deleted from our servers after 24 hours and download links will stop working after this time period.

FAQ

First, you need to add a file for conversion: drag & drop your PST file or click inside the white area to choose a file. Then click the "Convert" button. When PST to EML conversion is completed, you can download your EML file.

Of course! The download link of EML files will be available instantly after conversion. We delete uploaded files after 24 hours and the download links will stop working after this time period. No one has access to your files. File conversion (including PST is absolutely safe.

Yes, you can use our free PST to EML converter on any operating system that has a web browser. Our PST to EML converter works online and does not require any software installation.

Detailed examples are available at GitHub in the form of executable projects. If you are only interested in PST to EML conversion then check .NET & Java examples.

Читайте также:  Linux узнать размер свободного места

Other Supported Conversions

You can also convert PST into many other file formats. Please see the complete list below.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Handy scripts when working with PST files in Linux

EdgeSync/linux_pst_2_eml

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Working with PST files in Linux

I recently started working with PST files in linux — building a searchable mailbox archive from old PST files backed up from various mailboxes. In this project you will find scripts which i’ve used to help speed up some of the tasks needed to convert the PST files into easy use data.

First of all, you will need to install the following:

libpst4;xxxxx — xxxxx will be i386 or amd64 pst-utils readpst

On debian systems they can be installed like so:

sudo apt install libpst4:xxxxx pst-utils reaspst

if you are unsure which are available, you can do:

apt search libpst4 and so on to see if they are available in your repo’s.

This cycles through all your .pst files, and will convert each email to a .eml file in it’s respective directory. You may end up with a structure like this:

export/Archive/Inbox/*.eml
export/Archive/Folder 1/*.eml
export/Archive/Sent Items/*.eml
export/Archive/Deleted Items/*.eml

Use the script as following:

This script renames your eml files in all the various directories to have a unique name by renaming it to it’s md5 hash value. when it finds an eml file, it does md5sum on the file, then renames the file to hash.eml

This will be useful later when we want to de-duplicate any emails before we add them into a database.

If you have any suggestions, improvements or any kind of questions about the scripts, please feel free to reach out to me here. I will be adding more scripts as I build them.

About

Handy scripts when working with PST files in Linux

Источник

Оцените статью
Adblock
detector