Hi Roy
This uses the date instead of the ID and it works (sigh of relief.) If all the emails to be processed are going to have the same subject, some kind of identifier is necessary.
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with thisMessage in theMessages
set theText to content of thisMessage
tell thisMessage
set fileName to subject & "_" & (date received of thisMessage as string) & ".txt"
end tell
--this part removes colons from the file name so the path is correct
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set newName to (text items of fileName)
set AppleScript's text item delimiters to "_"
set fileName to newName as string
set AppleScript's text item delimiters to TID
set theFile to ((path to desktop folder) as string) & fileName
set theFileID to open for access file theFile with write permission
write theText to theFileID
close access theFileID
end repeat
end tell
end perform mail action with messages
end using terms from
I still like the ID because that is the only identifier on the .emlx file, but this is for your use so it’s your decision. I’m going to try to do it anyway, just for the learning experience.
I guess the next decision is the location of the folder for these files.
j