Merging Weird, Splitted Email Attachments as .DAT-files With [x/x] in Subject

A client received a large collection of emails today, where the sender’s software had split the mail into several parts. Outlook / Exchange at our end did however not understand the scheme the user had used to split the files, so the mails arrived as separate entities in the mailbox.

Each mail was named in the same manner:

filename [1_3].dat
filename [2_3].dat
filename [3_3].dat

After saving the files by themselves, it became clear that the files contained a set of mime encoded files (separated by –-=_NextPart_) (I first attempted to decode one of the files by itself as base64, which failed).

To decode these files, I saved all the different parts of the .dat to a directory, then appended the files together with cat *.dat > merged.dat. At least we have a complete version of the attachment.

To extract the files from the attachment, use munpack – available in the mpack package under Ubuntu.

munpack merged.dat extracts all the files from the .dat to the current directory.