naps2 icon indicating copy to clipboard operation
naps2 copied to clipboard

Use AppleScript for macOS email clients

Open pexner opened this issue 6 months ago • 5 comments

Set Email Settings to provider "Apple Mail". Scan Email All Result "beep" and nothing happens.

Expected behavior Mail.app opens, creates new mail and adds scan as attachment.

Tested on macOS 14 and 15.

pexner avatar May 15 '25 16:05 pexner

It works for me, but it sometimes creates the window for the new draft underneath the Inbox window.

Have you tried with the Mail app both open and closed?

cyanfish avatar May 15 '25 17:05 cyanfish

I found the issue. If the default application for mail is NOT Mail.app (settings in Mail.app Preference -> General) it's not working. My default aplication for mail is Outlook. But I use Mail.app for my personal mails. When setting Mail.app as default app, it's working. On Windows, naps2 offers more mail handling apps to use.

pexner avatar May 18 '25 17:05 pexner

I've had a look and unfortunately Apple doesn't really let apps talk to mail apps in the same way as Windows. I've made it so the Apple Mail option is disabled in 8.2.0 if it's not the default, so that people don't select it and then wonder why it's not working, but I don't think it's possible to have Mail.app work without it being the default.

cyanfish avatar Jun 08 '25 19:06 cyanfish

Thanks. I think it's easily possible to bypass this limit using AppleScript. It should even work with Outlook or other email apps which are scriptable. Am 09/06/2025 um 04:23 schrieb Ben Olden-Cooligan @.***>: Closed #620 as completed.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

pexner avatar Jun 10 '25 02:06 pexner

Fair. I'm not going to put in the effort to do that for each client but I'll leave open this issue in case someone wants to contribute a fix.

cyanfish avatar Jun 10 '25 04:06 cyanfish

I hope someone could implement this into naps2 to be in pair with the Windows version:

I found two easy ways to attach the scan to a new email of ANY mail-client app. One by AppleScript, one by Terminal command. On macOS it's easy to attach a file to a mail client by simply force open the file by a [any|mail]application.

The Terminal one-liner for this is: open /path/to/file -a 'Mail.app' or open /path/to/file -a 'Microsoft Outlook.app' or open in Preview: open /path/to/file -a 'Preview.app' or even any other App could be used for post-processing a scan from inside naps2. :)

The AppleScript looks similar.

set filepath to POSIX path of "/path/to/file"
try
	do shell script "open " & quoted form of filepath & " -a 'Mail.app'"
end try

pexner avatar Sep 11 '25 17:09 pexner