MessageID → Evernote

Das Script, welches die MessageID einer ausgewählten Mail kopiert und als eine HTML-Notiz in Evernote absichert, hatte ich schonmal vorgestellt.

(Hintergrund:
Ich möchte nicht immer die ganzen Mails nochmal in Evernote importieren, sondern gerne einfach aus einer Notiz in Evernote auf die Mail verlinken, sodass ich sie – auf allen Endgeräten – direkt aus Evernote im Mail Programm öffnen kann. Da Evernote das URL-Schema „message://…“ noch nicht nativ unterstützt und man daher die MessageID nicht direkt kopieren und einsetzen kann, ist der Klimmzug über eine HTML-Formatierung nötig. Immerhin funktioniert das zuverlässig.)

Das Script habe ich jetzt um eine Zeile ergänzt, um die so generierte Notiz in ein Notizbuch zu verschieben. Auf diese Weise ist sie direkt abgelegt und ich muss sie nicht aus der @Inbox händisch verschieben oder löschen.

Neu ist die Zeile:

move theNewNote to notebook „Mails“

Das Script habe ich als Automator-Dienst gespeichert und im Verzeichnis ~/Library/Services abgelegt. Mit dem Shortcut cmd-opt-ctrl-e kann ich das Script aus der Mail.app heraus aufrufen.

Das ist der Code:

on run {input, parameters}

tell application „Mail“

–get selected messages
set theSelection to selection

–loop through all selected messages
repeat with theMessage in theSelection

–get information from message
set theMessageDate to the date received of theMessage
set theMessageSubject to the subject of the theMessage
set theMessageURL to „message://%3c“ & theMessage’s message id & „%3e“
set theHTMLLink to „<a href=\“message:///%3c“ & theMessage’s message id & „%3e\“>→ Mail</a>“

–import message to Evernote
tell application „Evernote“

synchronize

set theNewNote to (create note with html (theHTMLLink))
set the title of theNewNote to „[MessageID] “ & theMessageSubject
set the source URL of theNewNote to theMessageURL
set the creation date of theNewNote to theMessageDate
move theNewNote to notebook „Mails“

synchronize

end tell

end repeat

end tell

return input

end run