I am looking for a script to open the (pdf) attachment in a (new) eMail using Mail.
Panascan. You can easily open an attachment in a new email with the context menu. Perhaps you could explain a bit more what you want the AppleScript to do.
I want to open the Mail attachment on command, not manually by using the mouse…
Any programming hints are welcome (which tool, which way?)
panascan. I am still not clear what specifically you want to do. FWIW, the following script opens every PDF attachment in a selected email with the default app (normally Preview). This creates temporary files for all the attachments, but I don’t know a way around that. Hopefully, another forum member will have a better understanding of your request and will be able to help.
set destinationFolder to (path to temporary items as text)
tell application "Mail"
set selectedMessages to selection
if selectedMessages is {} then display dialog "No Mail attachments were found" buttons {"OK"} cancel button 1 default button 1
repeat with aMessage in selectedMessages
repeat with anAttachment in mail attachments of aMessage
set theFile to (destinationFolder & (name of anAttachment))
save anAttachment in file theFile
openPDF(theFile) of me
end repeat
end repeat
end tell
on openPDF(theFile)
tell application "Finder"
if (name extension of file theFile) is "pdf" then open file theFile
end tell
end openPDF
We are on the right way. Thanks!
But this script just opens the attachment of a selected email.
But what I intend to do is to write a new email with an attached pdf-document. Before sending the email I would like to check the content of the pdf by calling a script to open the pdf (in Preview).
How could this been done?
panascan. There is an outgoing message
class that should allow an AppleScript to do what you want, but I could not get it to work reliably. Sorry about that. Hopefully another forum member will be able to assist you.
Have you tried Automator?