Quicksave and Rename Emails and Attachments like TechHit MessageSave for Outlook/Windows

Hi everyone,

Like many of you, I have one foot in Mac and the other in Windows. Because I like many of the Mac’s automation and productivity tools (OmniFocus, Devonthink, KeyboardMaestro) I’m trying to manage my email workflow off of my Mac through remote access on my computer at work, which must be windows.

One thing that is missing is a way to quick file emails. For my job, I must keep a running case chronology for each of my files, in case I drop dead, so that my replacement can easily review the case history. Most tedious is saving and renaming emails.

On Windows/Outlook, I have a plugin called MessageSave, which allows me to quick save any email message to a folder, through a quick/smart entry that finds the destination case file folder in OneDrive quickly. It automatically renames the email according to the following naming template:
YYYY.MM.DD.HHMM - EMAIL rec - fr NAME - to NAME - <Subject first 80 chars>

When I send an email, it prompts me to save that email as well if I wish according to this naming template:
YYYY.MM.DD.HHMM - EMAIL sent - to NAME - fr NAME - <Subject first 80 chars>

Any Attachments are are extracted from the email named accordingly with the same DATE format as the email , with the word ATTACH rather than EMAIL.

I use this naming convention for all documents related to that file named by date created or received, which creates a running chronology of the cases. I then use OneNote (maybe moving to Curio) to manipulate and sort documents as required to keep a Case Binder. I’ve also starting indexing my case folders in Devonthink which has improved searching for a specific item, even when I’m just remoting into my mac from my Windows computer at work.

Anyway, what I am looking for is a way to have this same auto renaming/autofiling capability on my mac. I’m open to a variety of options.

One option may be to have Devonthink rename emails in the indexed folder location, and I can just use the Devonthink quick filing options to quickly put the email in its place. Another option might be to use Hazel.

With either option, or another, I would want the ability to automagically rename the email according to my template, extract the attachments, and also automagically rename the attachments according to the same or similar naming nomenclature.

Does anyone have any suggestions?

All else fails, I could just continue to manage my email in outlook on my Windows computer and continue to use TechHIt. But then I’m missing out on the email integration features with OmniFocus (I don’t like to use email to omnifocus and prefer to quick add the email with a link right from Mail).

@talundbl I have some thoughts, which may (or may not) be helpful.

Firstly, there are some apps that have the capability to archive and/or store emails. The two that come to mind are DevonThink and EagleFiler, both of which do have email importing capabilities. If you are interested/willing to store your information in either app, this might be a quick solution.

I tried both, but did not stick with them in part because I was looking more for a solution that stored emails in my file system, and not in a separate app. I tend to go back and forth on whether I want to commit to DT or not.

Mail.app has the ability to export an email to a PDF, and it does generate a nicely formatted PDF. Attachments, however, are displayed either inline in the PDF (for short PDFs, for instance) or as icons. You can save attachments separately.

It is feasible to “automate” this process, saving the email as a PDF (or in raw email format) via UI scripting (for the PDF) or AppleScript (for an .eml file). I found the UI scripting (either in AppleScript or via KeyboardMaestro) to be flakey and unreliably and gave up on that eventually as well. However, if you are willing to do this as a more manual process, that might solve your problem.

I built my own system which I am, so far, reasonably satisfied with. The basis is a macro in KM to save any emails selected in Mail.app. The macro, in a macro group that is only active with Mail.app is the active application, simply runs through all selected emails and saves the raw email to a file on the Desktop, with a .eml extension. Interestingly, if you QuickLook such a file it will display in a readable and reasonable format, and of course having it as what is a plain text file with email headers does make it searchable via tools like grep and so forth. The filename contains both the message ID from Mail.app and the account the email was sent to for initial identification and to keep filenames unique when multiple messages have been put on the desktop.

The next step is a Hazel rule that runs after the file has been on the Desktop for some period of time (giving me a time interval in which to delete the .eml file, move it, or whatever, if I don’t want it to proceed down the automated process).

The Hazel rule picks up .eml files on the Desktop that have been there for the specified period of time, and runs my custom script (written in Python) which does the following: 1) renames the .eml file to a more useful filename formatted as YYYY-MMDD-HHMMSS_.eml and 2) pulls out all attachments and saves them in filenames of the format YYYY-MMDD-HHMMSS__.

The script has the capability to insert into the filename either a UUID or a SHA-256 hash of the raw message if desired, but I decided not to use that in production as it makes the filenames overly long, and was designed to avoid filename collisions which has not actually turned out to be a problem for me.

Special characters that don’t play well in filenames are removed, and spaces changed to underscores (which work much better in the shell).

The script also tags the attachments with a tag “attachment” and tags the renamed raw email file with “email” and if there are attachments, with “hasattachments.”

Since the script is in Python, the tagging is done with my own utility called Tagger, written in Swift.

In addition, the email file and attachments are tagged based on the email address to which they were addressed, pulled out of the email headers, and if that does not work, then from the filename, which has the account that Mail had assigned the email to. There is a dictionary in the Python code that specifies the tag to assigned based on the email account.

After all of this is done, Hazel will eventually pick up any files tagged email or attachment (again there is a delay in case I want to move or copy these files somewhere else, like a project folder) and will move them to my EmailArchive folder, where another Hazel rule will use the tag that was based on the recipient account to move them to a subfolder.

In the end, I can quickly save one or more emails from Mail.app using two keystrokes (one to pull up the conflict menu for Mail.app and a second to trigger the save macro) and eventually the files will wind up in my email archive folder. If I want, I can move or copy the files from the Desktop during the process if needed.

It’s a big convoluted, and there is some kludginess, but it does work.

One thing I would have liked would have been to render the email into a pdf file for easier viewing and printing at a later date but that provided very difficult. Scripting Mail.app to generate the PDF wound up being unreliable and slow, and so I finally decided to fall back to another approach: if I double click the .eml file, it will open in Mail.app where I can save to PDF or print, so if/when I need that functionality I can use that approach. I wish there was a more easily scriptable way to get Mail to output a message to a PDF, but there is not, and I decided that I did not want to put in what would be a fair amount of effort to write that code - I really don’t want to take on the complexity of parsing email to that level of detail, essentially replicating the development of a mail application. If I learn that one of the other popular Mac email apps supports this functionality via scripting, that may well push me to change!

Hope this far_to_long reply is useful. If you have interest, I am happy to share my code.

1 Like