with Matijs van Zuijlen's open source MSGConvert (aka Email::Outlook::Message).
Install:
sudo apt install libemail-outlook-message-perl
Recursively convert MSG files to EML files, saving in their respective directories:
find /path/to/msgs/ -iname "*.msg" -type f -print0 | xargs -0 -I{} bash -c 'msgconvert "{}" -o "$(dirname "{}")/$(basename "{}" .msg).eml"'
Recursively convert and combine MSG files into a single MBOX file:
find /path/to/msgs/ -iname "*.msg" -type f -print0 | xargs -0 msgconvert --mbox combined.mbox
Other install options include cpan -i Email::Outlook::Message or building from source with dependencies.
MSG files remain intact.
Current version of msgconvert is 0.921; check via grep '^\$VERSION' /usr/bin/msgconvert or perl -MEmail::Outlook::Message -e 'print $Email::Outlook::Message::VERSION, "\n";'
In WSL's Ubuntu 22.04.3 LTS, sudo apt install libemail-outlook-message-perl returned E: Unable to locate package libemail-outlook-message-perl; ran sudo apt update to resolve.
Under Ubuntu 24.04 LTS ARM, msgconvert 0.921 returned Value for 'Subject' header with wide characters at /usr/share/perl5/Email/Outlook/Message.pm line 320. when converting a certain email, though the conversion appeared to complete normally (this error did not occur under Ubuntu 22.04.4 LTS ARM with the same version of msgconvert). Changing header_set to header_str_set in line 320 of /usr/share/perl5/Email/Outlook/Message.pm, as described in PR 44 and Issue 49, resolved the error.
H/T: Georg Jung
/nix | May 24, 2024