On Saturday, 4 October 2003, cheshirekat, [EMAIL PROTECTED],
thoughtfully composed the following:
>How can I access the HTML of a message from an AppleScript? I have a few
>people who send me HTML documents that I need to automatically do some
>stuff to as soon as they come in. I assumed that the HTML would be an
>attachment, but the AppleScripts I've used successfully with other types
>of attachments always work - not so with HTML. When I click on the globe
>at the bottom of a message window, what shows up in the browser as a URL
>for a file of "message.html" in the attachments folder for all HTML, with
>only a few that have been separate HTML documents with identifiable
>names/paths.
Here's a script that will get the text of a HTML message, whether it's a
standard HTML message, or one that comes as an attachment:
tell application "PowerMail"
set myMessages to current messages
repeat with aMessage in myMessages
if exists (attachments of aMessage) then
set fileList to attachments of aMessage
repeat with theFile in fileList
set fname to theFile's name
if fname contains ".htm" then
set myFile to theFile's file
set theText to my readFile(myFile)
--do stuff with theText
end if
end repeat
else
set theText to aMessage's source
-- do stuff with theText
end if
end repeat
end tell
on readFile(theFile)
read theFile
end readFile
It's a bit either/or, but I hope it helps. I had to put the read command
in a separate handler, to fix what looks like a terminology conflict with PM.
I s'pose I should explain it a bit, but it's late here, and I've had a few ;-)
Marcus
--
Marcus Jarrett
Adelaide, South Australia
[EMAIL PROTECTED]