<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">This is supercalifragilisticexpialidocious, Carlos!</p>
<p dir="auto">Thanks a lot!</p>
<p dir="auto">On 22 Mar 2024, at 1:26, Carlos Moffat wrote:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; color: #136BCE;">
<p dir="auto">Hi,</p>
<p dir="auto">What I do to solve this problem is:</p>
<ol>
<li>
<p dir="auto">Set a smart folder that saves the messages that match the conditions to a folder (with Rules->Export to Folder).</p>
</li>
<li>
<p dir="auto">Use the app Hazel to watch that folder, and when new messages are added, run a python script that extracts the attachment. I think this could be done with a macOS service as well, or with Keyboard Maestro’s ‘folder’ trigger.</p>
</li>
<li>
<p dir="auto">Hazel then moves the processed message to a subfolder called ‘processed’.</p>
</li>
</ol>
<p dir="auto">the python code (which I call ‘get_email_attachments.py’) is pretty simple, copied below.</p>
<p dir="auto">Cheers,<br>
Carlos</p>
<p dir="auto">#!/usr/bin/env python</p>
<p dir="auto">import email<br>
import sys<br>
import os<br>
import time</p>
<p dir="auto">listing = sys.argv</p>
<p dir="auto">for fle in listing:<br>
if str.lower(fle[-3:])=="eml":<br>
msg = email.message_from_file(open(fle))<br>
attachments=msg.get_payload()<br>
date=email.utils.parsedate_to_datetime(msg['Date']).strftime('%Y.%m.%d')<br>
for attachment in attachments:<br>
fnam=attachment.get_filename()<br>
if fnam is not None:<br>
content = attachment.get_payload(decode=True)<br>
outname = date + '-' + fnam<br>
print(outname)<br>
f = open(outname,'wb')<br>
f = f.write(content)</p>
<p dir="auto">On 12 Feb 2024, at 4:36, Scott wrote:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; border-left-color: #4B89CF; color: #4B89CF;">
<p dir="auto">Hi,</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; border-left-color: #4B89CF; color: #4B89CF;">
<p dir="auto">No, I haven’t found a solution yet.</p>
<p dir="auto">Maybe it is possible to develop a bundle which extracts attachments to folders?</p>
<p dir="auto">But good to know I’m not alone here with this need….</p>
</blockquote>
<p dir="auto">I have a similar need, and I almost found a solution...using Keyboard Maestro.</p>
<p dir="auto">I don't want to do it all the time for every message that arrives in a specific mailbox, so, not quite the same use as you and Stefan.</p>
<p dir="auto">Instead, I have a selection of messages that I want to extract the attachments from to a specific folder.</p>
<p dir="auto">I created a Keyboard Maestro macro to select all of the messages in that mailbox, and then select the Message -> Save Attachments shortcut in MailMate.</p>
<p dir="auto">Unfortunately, this is where things start behaving unpredictably.</p>
<p dir="auto">In the panel that appears, if you type a path (there is no text input area, but if you just start typing as if you're typing a path/directory), then the panel for saving the attachments will change to that directory.</p>
<p dir="auto">That's a macOS feature, not MailMate.</p>
<p dir="auto">But however Keyboard Maestro types text doesn't always play nicely with this process (I've tried all of the ways KM has).</p>
<p dir="auto">I suspect that if I had the KM Macro run some AppleScript that sent text more like a person typing, it may work, but, I've not tested this.</p>
<p dir="auto">Not quite the fully automated way that you want to do things, but, I'm nearly there with this approach.</p>
<p dir="auto">Scott</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; border-left-color: #4B89CF; color: #4B89CF;">
<p dir="auto">Thanks,<br>
Leo</p>
<p dir="auto">On 26 Jan 2024, at 19:25, Stefan Dorscht wrote:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; border-left-color: #4B89CF; color: #4B89CF;">
<p dir="auto">Hello Leo</p>
<p dir="auto">Is there a solution for your request?</p>
<p dir="auto">I have a similar request here, I would like to export attachments from mails (with one or more attachments - some without attachments which shouldn’t be touched) to folders on my Mac.</p>
<p dir="auto">It would be ideal if all the attachments of each mail were placed in a single new folder.<br>
It would be even better if this folder then also had the name of the sender of the mail.</p>
<p dir="auto">Any hints?</p>
<p dir="auto">I am gratefuil for any help</p>
<p dir="auto">Stefan Dorscht</p>
<p dir="auto">Am 13.09.2023 um 5:39 Uhr schrieb leo:</p>
<blockquote style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136BCE; border-left-color: #4B89CF; color: #4B89CF;">
<p dir="auto">Hi there</p>
<p dir="auto">From some incoming mail messages is there a way to extracts its attachments to a folder?</p>
<p dir="auto">I am thinking of setting up a Smart Mailbox, but in the <em>Actions</em> for the Mailboxes <em>Rules</em> I couldn’t find anything which acts on attachments…</p>
<p dir="auto">Many thanks for any help,<br>
Leo_______________________________________________<br>
mailmate mailing list<br>
<a href="mailto:mailmate@lists.freron.com">mailmate@lists.freron.com</a><br>
<a href="https://lists.freron.com/listinfo/mailmate">https://lists.freron.com/listinfo/mailmate</a>_______________________________________________</p>
</blockquote>
<p dir="auto">mailmate mailing list<br>
<a href="mailto:mailmate@lists.freron.com">mailmate@lists.freron.com</a><br>
<a href="https://lists.freron.com/listinfo/mailmate">https://lists.freron.com/listinfo/mailmate</a>_______________________________________________</p>
</blockquote>
<p dir="auto">mailmate mailing list<br>
<a href="mailto:mailmate@lists.freron.com">mailmate@lists.freron.com</a><br>
<a href="https://lists.freron.com/listinfo/mailmate">https://lists.freron.com/listinfo/mailmate</a></p>
</blockquote>
<hr>
<p dir="auto">mailmate mailing list<br>
<a href="mailto:mailmate@lists.freron.com">mailmate@lists.freron.com</a><br>
<a href="https://lists.freron.com/listinfo/mailmate">https://lists.freron.com/listinfo/mailmate</a></p>
</blockquote>
<hr>
<p dir="auto">mailmate mailing list<br>
<a href="mailto:mailmate@lists.freron.com">mailmate@lists.freron.com</a><br>
<a href="https://lists.freron.com/listinfo/mailmate">https://lists.freron.com/listinfo/mailmate</a></p>
</blockquote>
</div>
</div>
</body>
</html>