Exporting/archiving email from Mail.app #

Michael Tsai has hosted a long-running discussion on data loss in Mail.app starting in Catalina and continuing unabated through Big Sur and Monterey (I have settled on only moving messages from IMAP servers to local storage via Thunderbird).

Further, Mail's built-in export (and import) methods suffer from various limitations and bugs; the following tests were run under macOS 12.4 and Mail 16.0 (3696.100.31):

1. Mailbox → Export Mailbox...

  1. Creates a single MBOX file containing all messages (actually a slightly nonstandard folder with the mbox file named "mbox" and another file named "table_of_contents").

  2. Pro: Successfully exported all messages.

  3. Con: Attempting to import such MBOX files (containing any significant number of messages) back into Mail generally fails with the following error: Some messages could not be imported. The partially imported mailboxes are located in the mailbox named "Import" in the mailboxes list.

  4. While Mail displayed a count of 4611 messages for the mailbox, 4618 were shown in Claws Mail and Thunderbird after import.

2. Click and drag multiple messages from Mail to Finder

  1. Creates a single EML file per message (converting from Mail's native EMLX format, which stores attachments separately) as opposed to MBOX's monolithic single file format.

  2. Pro: Works on even large numbers of messages (tested on a selection of over 10,000 - see below).

  3. Con: Silently fails to export messages with subject lines 252 characters or longer.

  4. When performed on the aforementioned mailbox (which Mail showed as containing 4611 messages while the exported MBOX file was reported to hold 4618), only 4600 messages were exported. The missing messages all had subject lines over 251 characters in length. This was verified by getting a list of all subjects in the mailbox via AppleScript (which also returned 4618 instead of 4611):

    tell application "Mail" to get the subject of every message of mailbox "foo"
    set subjectList to result
    set AppleScript's text item delimiters to "\n"
    set subject1PerLine to subjectList as string
    get subject1PerLine

    then locating those containing 252 or more characters: grep '.\{252\}' subjects.txt. Sure enough, the difference was exactly 18.

  5. Mail reported 10,663 messages in another mailbox; however, clicking and dragging them to a folder in Finder resulted in 10,672 EML files, indicating once again that Mail has a hard time keeping track of messages.

3. AppleScript

  1. Tom Floeren's 2017 "Export Selected Mail Messages" AppleScript still runs under Monterey, exporting highlighted messages to EML files.

  2. Pro: Truncates subjects/filenames over 180 characters to avoid the con described in 2c.

  3. Con: 31 messages were missing from the export after the script terminated with Script Error: AppleEvent timed out. Happily, this was easily rectified by adding with timeout of 3600 seconds above repeat with i from 1 to count of msgSubjects and end timeout below end repeat; afterwards, all messages exported successfully.

  4. As in 1d and 2d above, 4618 messages were exported from the mailbox which Mail had reported as containing 4611 messages. As a final test, ran this simple AppleScript oneliner to get the number of messages in the mailbox: tell application "Mail" to get the count of messages of mailbox "foo"; the result was 4618.

  5. Updated script:

4. partial-emlx-converter

  1. Open source script that "converts .emlx and .partial.emlx files written by Apple's Mail.app into fully self-contained, 'stand alone' .eml files."

  2. The author, Philipp Katz, relates that "one of my IMAP mailboxes went out of service and I was not able to copy all the messages to a different account with Mail.app, even though all mails and attachments were there (see here for the story). That’s why I created this script."

  3. Pro: Successfully converted all 4618 messages in test mailbox to EML format.

  4. Con: Not native.

/mac | Jun 14, 2022

Virtualizing Linux, macOS, and Windows ARM64 versions on an M1 Mac #

posted to the docs section.

/mac | Jun 11, 2022

Workflow for scanning/digitizing books #

  1. Scan with smartphone or tablet to JPG via vFlat Scan (Android | iOS)
  2. Clean up scans and convert to B&W TIF via ScanTailor Advanced or ScanTailor Universal
  3. OCR and convert to PDF via Adobe Acrobat

/misc | May 20, 2022

Restore macOS Contacts from Time Machine backup #

or any other backup of ~"/Library/Application Support/AddressBook/".

Caution

No consideration is given here to iCloud Contacts sync (though thermo2's 20-step procedure is reproduced below without prejudice). Back up, back up, back up and understand what you are doing. Contacts.app needs to be closed before attempting all methods but the first.

Method 1

Open Contacts.app then "Enter Time Machine" from menu bar icon to restore (H/T). Note that the "Browse Other Backup Disks..." option accessed by Option-clicking the Time Machine menu bar icon really means "Browse Other Backup Disks for the current device". (UPDATE: Michael Tsai reports that this method does not work in Monterey; further, he shared that Time Machine restores in apps other than Finder have not worked for him since around Mojave.)

Method 2

Replace ~"/Library/Application Support/AddressBook/" folder with backup copy of same (tested successfully in High Sierra, Mojave, Catalina, Big Sur, and Monterey).

Method 3

Add .abbu extension to backup copy of ~"/Library/Application Support/AddressBook/" then double click to import (tested successfully in modern macOS versions; similar to above method, but might make importing recovered data simpler for end users).

Method 4

Replace ~"/Library/Application Support/AddressBook/AddressBook-v22.abcddb" with backup copy of same (tested successfully in Lion, but failed in modern macOS versions).

Method 5

  1. Delete contents of ~"/Library/Application Support/AddressBook/".

  2. Paste the Metadata folder containing .abcdp files (found at either ~"/Library/Application Support/AddressBook/Metadata/" or ~"/Library/Application Support/AddressBook/Sources/UUID/Metadata/") from backup copy into ~"/Library/Application Support/AddressBook/".

  3. Launch Contacts.app; it will recreate AddressBook-v22.abcddb from the .abcdp files in Metadata/ (tested successfully in High Sierra and Mojave, even for Metadata folders created under newer versions of macOS (which is fortunate, as the process failed in Catalina, Big Sur, and Monterey; after exporting a Contacts Archive from Mojave, it was successfully restored to Big Sur, though logging off and on was required for the contacts to appear)).

Related

/mac | May 19, 2022

Twitter feed shutting down #

For those who wish to continue receiving updates, please subscribe via RSS.

/misc | Apr 26, 2022

Imaging and recovering data from floppy disks #

DOS

Linux

Windows

Hardware

Related

/misc | Apr 17, 2022

macOS: Find file extensions associated with an app #

Shortcat would not import its license file (named "shortcat-license") through the "Add License" button (where the file appeared as greyed out), via drag and drop into the License window, or via drag and drop onto Shortcat.app.

Resolved by finding which file extension Shortcat was associated with in /Applications/Shortcat.app/Contents/Info.plist → CFBundleTypeExtensions*:

<key>CFBundleTypeExtensions</key>
<array>
    <string>shortcat-license</string>
</array>

Just needed to add any filename and a dot before "shortcat-license", which turned out to be an extension rather than a filename.

* From the CFBundleDocumentTypes documentation:

Key: CFBundleTypeExtensions
Xcode name: "Document Extensions"
Description: This key contains an array of strings. Each string contains a filename extension (minus the leading period) to map to this document type. To open documents with any extension, specify an extension with a single asterisk "*". (In OS X v10.4, this key is ignored if the LSItemContentTypes key is present.) Deprecated in OS X v10.5.

/mac | Mar 25, 2022

Get macOS installers (app, dmg, iso, pkg) and firmware (ipsw) #

with the free and open source MIST - macOS Installer Super Tool:

% mist list
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ Kind will be 'installer'...
  ├─ Include betas in search results will be 'false'...
  ├─ Output type will be 'ascii'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS Installer versions...
  └─ Found 23 macOS Installer(s) available for download

Identifier │ Name              │ Version │ Build   │ Size     │ Date
───────────┼───────────────────┼─────────┼─────────┼──────────┼───────────
071-08758  │ macOS Monterey    │ 12.3    │ 21E230  │ 12.23 GB │ 2022-03-14
002-66265  │ macOS Monterey    │ 12.2.1  │ 21D62   │ 12.16 GB │ 2022-02-17
002-57041  │ macOS Monterey    │ 12.2    │ 21D49   │ 12.16 GB │ 2022-01-26
002-42435  │ macOS Monterey    │ 12.1    │ 21C52   │ 12.16 GB │ 2022-01-14
002-23774  │ macOS Monterey    │ 12.0.1  │ 21A559  │ 12.13 GB │ 2021-12-01
002-77154  │ macOS Big Sur     │ 11.6.5  │ 20G527  │ 12.42 GB │ 2022-03-14
002-65695  │ macOS Big Sur     │ 11.6.4  │ 20G417  │ 12.45 GB │ 2022-02-17
002-57023  │ macOS Big Sur     │ 11.6.3  │ 20G415  │ 12.44 GB │ 2022-01-26
002-42341  │ macOS Big Sur     │ 11.6.2  │ 20G314  │ 12.44 GB │ 2022-01-14
002-23589  │ macOS Big Sur     │ 11.6.1  │ 20G224  │ 12.43 GB │ 2021-12-01
071-78704  │ macOS Big Sur     │ 11.5.2  │ 20G95   │ 12.45 GB │ 2021-08-18
001-68446  │ macOS Catalina    │ 10.15.7 │ 19H15   │ 08.75 GB │ 2020-11-11
001-57224  │ macOS Catalina    │ 10.15.7 │ 19H4    │ 08.75 GB │ 2020-10-27
001-51042  │ macOS Catalina    │ 10.15.7 │ 19H2    │ 08.75 GB │ 2020-09-24
001-36801  │ macOS Catalina    │ 10.15.6 │ 19G2021 │ 08.75 GB │ 2020-08-12
001-36735  │ macOS Catalina    │ 10.15.6 │ 19G2006 │ 08.75 GB │ 2020-08-06
001-15219  │ macOS Catalina    │ 10.15.5 │ 19F2200 │ 08.74 GB │ 2020-06-15
001-04366  │ macOS Catalina    │ 10.15.4 │ 19E2269 │ 08.75 GB │ 2020-05-04
061-86291  │ macOS Catalina    │ 10.15.3 │ 19D2064 │ 08.69 GB │ 2020-03-23
061-26589  │ macOS Mojave      │ 10.14.6 │ 18G103  │ 06.52 GB │ 2019-10-14
061-26578  │ macOS Mojave      │ 10.14.5 │ 18F2059 │ 06.52 GB │ 2019-10-14
041-88800  │ macOS Mojave      │ 10.14.4 │ 18E2034 │ 06.53 GB │ 2019-10-23
041-91758  │ macOS High Sierra │ 10.13.6 │ 17G66   │ 05.71 GB │ 2019-10-19

/mac | Mar 24, 2022

macOS: Mount exFAT partitions created in Windows #

0. Issue

An 8TB USB HDD formatted as exFAT in Windows 10 (using the default settings) would not mount in macOS 12.

Disk Utility showed the exFAT partition greyed out. Right clicking it and selecting "Mount" returned:

Could not mount “8TB”. (com.apple.DiskManagement.disenter error 49223.)

Terminal fared no better:

   % sudo mount -t exfat /dev/disk2s2 ~/mnt
   mount_exfat: /dev/disk2s2 on /Users/user/mnt: Invalid argument
   mount: /Users/user/mnt failed with 71

1. Cause

Seagate's Disk Utility Errors and Questions for macOS 10.11 and higher explains:

Error Message - com.apple.DiskManagement.disenter error 49223
This error message has been seen with drives formatted ExFAT. When using a drive between macOS and Windows, drives should always be formatted on macOS because not all Windows allocation unit sizes (block sizes) are supported by macOS. An unsupported allocation unit size will keep the drive from mounting. This error will be displayed when trying to mount the drive manually with Disk Utility. If you are using this drive between macOS and Windows then back up any important data on the drive and reformat the drive ExFAT on macOS.

2. Solution

Rather than reformatting, exFAT for FUSE (which supports clusters up to 32 MB) was used to successfully mount the partition in macOS:

% sudo /usr/local/sbin/mount.exfat-fuse /dev/disk2s2 ~/mnt

3. Prevention

Finding only incomplete or incorrect guidance online, I decided to test every allocation unit size displayed in the Windows format GUI:

2048 bytes
4096 bytes
8192 bytes
16 kilobytes
32 kilobytes
64 kilobytes
128 kilobytes
256 kilobytes
512 kilobytes
1024 kilobytes
2048 kilobytes
4096 kilobytes
8192 kilobytes
16384 kilobytes
32768 kilobytes

(as well as the two smaller options, 512 and 1024 bytes, offered in the CLI), prepping partitions via the command prompt, e.g., C:\>format Z: /fs:exfat /v:test /q /a:128k .

macOS was able to natively mount exFAT partitions with cluster sizes from 512 bytes to 1024 KB, but not from 2048 KB through 32768 KB.

4. Notes

/mac | Mar 04, 2022

3 cross-platform email tools #

/misc | Jan 10, 2022


Subscribe or visit the archives.