This is supercalifragilisticexpialidocious, Carlos!

Thanks a lot!

On 22 Mar 2024, at 1:26, Carlos Moffat wrote:

Hi,

What I do to solve this problem is:

1) Set a smart folder that saves the messages that match the conditions to a folder (with Rules->Export to Folder).

2) 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.

3) Hazel then moves the processed message to a subfolder called ‘processed’.

the python code (which I call ‘get_email_attachments.py’) is pretty simple, copied below.

Cheers,
Carlos

#!/usr/bin/env python

import email
import sys
import os
import time

listing = sys.argv

for fle in listing:
    if str.lower(fle[-3:])=="eml":
        msg = email.message_from_file(open(fle))
        attachments=msg.get_payload()
        date=email.utils.parsedate_to_datetime(msg['Date']).strftime('%Y.%m.%d')
        for attachment in attachments:
            fnam=attachment.get_filename()
            if fnam is not None:
                content = attachment.get_payload(decode=True)
                outname = date + '-' + fnam
                print(outname)
                f = open(outname,'wb')
                f = f.write(content)




On 12 Feb 2024, at 4:36, Scott wrote:

Hi,

No, I haven’t found a solution yet.

Maybe it is possible to develop a bundle which extracts attachments to folders?

But good to know I’m not alone here with this need….

I have a similar need, and I almost found a solution...using Keyboard Maestro.

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.

Instead, I have a selection of messages that I want to extract the attachments from to a specific folder.

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.

Unfortunately, this is where things start behaving unpredictably.

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.

That's a macOS feature, not MailMate.

But however Keyboard Maestro types text doesn't always play nicely with this process (I've tried all of the ways KM has).

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.

Not quite the fully automated way that you want to do things, but, I'm nearly there with this approach.

Scott






Thanks,
Leo

On 26 Jan 2024, at 19:25, Stefan Dorscht wrote:

Hello Leo

Is there a solution for your request?

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.

It would be ideal if all the attachments of each mail were placed in a single new folder. It would be even better if this folder then also had the name of the sender of the mail.

Any hints?

I am gratefuil for any help

Stefan Dorscht

Am 13.09.2023 um 5:39 Uhr schrieb leo:

Hi there

From some incoming mail messages is there a way to extracts its attachments to a folder?

I am thinking of setting up a Smart Mailbox, but in the *Actions* for the Mailboxes _Rules_ I couldn’t find anything which acts on attachments…

Many thanks for any help,
Leo_______________________________________________
mailmate mailing list
mailmate@lists.freron.com
https://lists.freron.com/listinfo/mailmate_______________________________________________
mailmate mailing list
mailmate@lists.freron.com
https://lists.freron.com/listinfo/mailmate_______________________________________________
mailmate mailing list
mailmate@lists.freron.com
https://lists.freron.com/listinfo/mailmate
_______________________________________________
mailmate mailing list
mailmate@lists.freron.com
https://lists.freron.com/listinfo/mailmate
_______________________________________________
mailmate mailing list
mailmate@lists.freron.com
https://lists.freron.com/listinfo/mailmate
_______________________________________________
mailmate mailing list
mailmate@lists.freron.com
https://lists.freron.com/listinfo/mailmate

Reply via email to