Hello, friends.
Thanks for being such a great help to applescript beginners like me.
Another situation and question:
I am still working on a script for Mail that allows me to select a message, run the script from the Mail scripts menu, and end up with a task in Entourage that has the subject of the message in the subject line of the task and the content of the message in the notes section of the task. This has been a fun challenge, and I’m getting closer every day.
Here’s the most recent issue: When I try to run this with an html message in Mail, the content of the message turns out as garblygook in Entourage. When I try to run this with a plain text message in Mail, the content comes out just like I want it.
So, my proposed solution is to change the content of the message to plain text before storing it in the variable that will be used in Entourage in the future. However, I Mail won’t let me force the content to string or Unicode text and “message format” or some such property is not available in the dictionary of Mail as far as I can tell.
So, I’m trying to
- use System Events to “keystroke” the keyboard shortcut in Mail (command-option-p) that will switch the message to plain text,
- store the content in the variable
- use System Events to “keystroke” the keyboard shortcut in Mail (command-]) to switch it back to html
Here’s the pertinent part of the script…
tell application "Mail"
set theMessages to selection
repeat with eachMessage in theMessages
tell application "Mail" to activate
tell application "System Events" to keystroke "p" using {command down, option down}
set theContent to content of eachMessage
tell application "System Events" to keystroke "]" using command down
end repeat
end tell
This works fine when I run it from Script Editor. However, if I save it in the scripts menu for “Mail” and run it from there, it doesn’t work.
Any ideas?
David Wilcox
Model: Powerbook G4
AppleScript: Applescript 1.9.3
Browser: Firefox 1.0
Operating System: Mac OS X (10.3.9)