In macOS you can obtain (explained here how) the URL to a specific email. So that if you click to the that URL, or you paste it into a browser search bar, that specific email will open in Mail.app.
Such a URL looks like this message://<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com>
In Catalina I could use the command open
to reach such a URL from the command line, by typing
open -a "Mail.app" "message://<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com>"
But with BigSur if I try that I get the following error
The file /Users/macbook/message:/<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com> does not exist.
This behavior seems to be related to a bug in BigSur.
Two question
Do you know if the
open
command can still be used for that task somehow?Alternatively, I am looking for a workaround. It must be possible to achieve the behavior I am expecting because if you past a
message://
URL in Chrome, Safari or in a rich text editor which supports hyperlinks, it is correctly handled.
I have tried, unsuccessfully many approaches.
Swift script
import AppKit
NSWorkspace.shared.open(URL(string: "message://<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com>")!)
The URL is nil
.
Apple Script
tell application "Mail"
activate
open location "message://<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com>"
end tell
I am not sure if the above code would have worked in Catalina, I just know that in my case it just opens the Mail app without doing anything else.
Using Chrome
If you paste a message://
URL in Chrome it asks you to confirm that you want to open it in the Mail app. This can be overridden with the following command:
defaults write com.google.Chrome URLWhitelist -array 'message://*'
Asking Chrome to open a URL for you looks like a easier task, but still the command
open -a "Google Chrome" "message://<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com>"
fails with an error similar to the one shown before:
LoR5A+vANPG9eCcHRHnO@mail.gmail.com>"
The file /Users/macbook/message:/<CALoR5A+vANPG9eCcHRHnO@mail.gmail.com> does not exist.
Any ideas?