Re: Send selected messages as attachments in Mail.app
Re: Send selected messages as attachments in Mail.app
- Subject: Re: Send selected messages as attachments in Mail.app
- From: Le Stang Jean-Baptiste <email@hidden>
- Date: Fri, 15 Dec 2006 21:39:05 +0100
Do not forget to wrap the whole script in a 'tell … end tell'
structure :
tell application "Mail"
set theList to get selected messages of first message viewer
set theFileList to {}
repeat with x in theList
set myFile to (do shell script "mktemp -t mail")
set myFileFp to open for access myFile with write permission
write (get source of x) to myFileFp
close access myFileFp
set end of theFileList to myFile
end repeat
end tell
About the authentication problem, I cannot help you very much, maybe
XMail will support the use of keychain in a future version (who
knows…) but you might consider composing your mail in Mail instead of
using XMail :
<shame on me>
tell application "Mail"
set theList to get selected messages of first message viewer
set theFileList to {}
repeat with x in theList
set myFile to (do shell script "mktemp -t mail")
set myFileFp to open for access myFile with write permission
write (get source of x) to myFileFp
close access myFileFp
set end of theFileList to myFile
end repeat
set newMessage to make new outgoing message with properties
{content:return & return}
tell newMessage
set subject to "My spam report gnagnagna …"
repeat with i in theFileList
tell content
make new attachment with properties {file name:i} at after the
last paragraph
end tell
end repeat
make new to recipient with properties {address:"email@hidden"}
end tell
send newMessage
end tell
</shame on me>
--
Jean-Baptiste
send mail to "email@hidden" from "email@hidden" subject "my test"
body "my message" attachments theFileList SMTP server "localhost"
On Dec 15, 2006, at 8:56 PM, Justin wrote:
Thanks so much for your reply, Jean-Baptiste!
The following script will take every selected messages and attach
them to a new mail message
I couldn't get the script below to compile, unfortunately. :( The
error I
received was:
Syntax Error: A identifier can't go after this property. [selected
messages]
you can of course replace the use of 'send mail' (this verb comes
with the
XMail osax, http://lestang.org/ osax/XMail) by a piece of script
that will
create a mail message in Mail and then add attachments to it but
XMail
makes things more compact :p
XMail looks like a handy extension, indeed! The only problem with this
approach is that we use authenticated SMTP. While we could embed
the user's
name and password into the script, that's less than ideal for
security and
ease-of-script-distribution reasons.
That said, I'd be thrilled (for starters) to get your script
working. Any
thoughts as to how I might get around the compilation issue
mentioned above?
Sincere thanks in advance,
Justin
From: Le Stang Jean-Baptiste <email@hidden>
Date: Sat, 9 Dec 2006 10:39:16 +0100
To: Justin <email@hidden>
Cc: <email@hidden>
Subject: Re: Send selected messages as attachments in Mail.app
Hello,
The following script will take every selected messages and attach
them to a new mail message, you can of course replace the use of
'send mail' (this verb comes with the XMail osax, http://lestang.org/
osax/XMail) by a piece of script that will create a mail message in
Mail and then add attachments to it but XMail makes things more
compact :p
set theList to get selected messages of first message viewer
set theFileList to {}
repeat with x in theList
set myFile to (POSIX file (do shell script "mktemp -t mail"))
set myFileFp to open for access myFile with write permission
write (get source of x) to myFileFp
close access myFileFp
set end of theFileList to myFile
end repeat
send mail to "email@hidden" from "email@hidden" subject "my test"
body "my message" attachments theFileList SMTP server "localhost"
On Dec 8, 2006, at 4:49 PM, Justin wrote:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden