This is the script:
**********
property spamAddr : "
[email protected]"
tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:currentMessages}
end tell
**********
Any suggestions?
Aside from Diane's news that it's been done already, if you'd like to learn
what's going wrong here, take a look at the Entourage Dictionary:
Class attachment: An attachment to a message
Plural form:
attachments
Properties:
name Unicode text [r/o] -- the name of the attachment
file type type class [r/o] -- the type of file
file creator type class [r/o] -- the creator of file
encoding no encoding/7bit encoding/8bit
encoding/binhex/base64/uuencode/AppleSingle/AppleDouble/quoted
printable/unknown encoding [r/o] -- the MIME encoding of the data
file alias [r/o] -- alias to the associated file (if there is one)
content string [r/o] -- the encoded content (if it has been encoded)
properties record -- property that allows setting a list of properties
Virtually everything is read-only aside from 'properties', which will allow
you to set the properties when you're creating an attachment. Almost all the
other properties are a "given" once the attachment has been decided (name,
file type, file creator, etc.): this stuff is mostly useful for querying
attachments you receive, not ones you send. What's left? 'content' and
'file'. Even 'content' is really just for receive attachments, although I
might play with its and see if getting the encoded source of an email
message and setting the content might just work - chances are it won't,
because of all the special extra headers attachments need.
So that leaves just 'file'. Perhaps you know how to use that one to make a
file ('alias') on your hard disk into an attachment for a message. So how do
you use it to make a _message_, not a file, into an attachment? Well, you
simply first save the message to disk as a file, then make that file into an
attachment. In fact, that's what Entourage itself has to do - that's why you
have an "Entourage Temp" folder in your Microsoft User data folder. That's
where Entourage makes temporary files it needs for making attachments out of
messages (.eml files), contacts (vCards - .vcf files) ) and calendar
invitations (.ics files) - dragged directly from some part of Entourage. So
you could use the same Entourage Temp folder - which empties itself when
Entourage quits. Personally, if I were writing a script to distribute I
would use Apple's own 'temporary items' folder for each OS X user, because
you can specify it for any language. "Entourage Temp" will have a different
name in non-English versions of Entourage, and there's no AppleScript term
for finding it. The user 'temporary items' folder is an invisible folder
that has lots of stuff, and empties when you log out or reboot or shut down.
Because you're making a file by AppleScript, you also have to replace any
colon in the attachment's name with a "-": AppleScript won't accept ":" in a
file's name. Another thing is that 'save' doesn't have a result, so you have
to "look for" the saved message after you save it.
Here's how I'd do it:
property spamAddr : "
[email protected]"
set tempFolderPath to (path to temporary items as Unicode text)
tell application "Microsoft Entourage"
set currentMessages to the current messages
set src to "I have some spam to report." & return & return & "Thank
you."
set theFiles to {}
repeat with i from 1 to (count currentMessages)
set theMessage to item i of currentMessages
set theSubject to subject of theMessage
set AppleScript's text item delimiters to {":"}
set wordList to text items of theSubject
set AppleScript's text item delimiters to {"-"}
set theSubject to wordList as Unicode text
save theMessage in (tempFolderPath & theSubject) -- just the path
set theFile to alias (tempFolderPath & theSubject) --actual file
set end of theFiles to theFile
end repeat
set AppleScript's text item delimiters to {""}
make new outgoing message at out box folder with properties ¬
{content:src, subject:"Spam report", recipient:spamAddr,
attachment:theFiles}
end tell
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page:
http://www.entourage.mvps.org/toc.html
Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.
PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.