Script to set up email header

i am trying to make a script that automatically fills in the TO: line, the SUBJECT: line, and some of the body.

the variables i am using are

set default_address to "whatever@whatever.com"
set default_content to "some text"
set default_subject to "some subject"

can anybody help?

If you already have a message opened and just want to fill in this info you should use.


Tell application "Mail"
--This assumes that the message you want to work with is the last one you created (e.g., the most recently opened one.)
set theMessage to (last outgoing message)
set default_address to "whatever@whatever.com" 
set default_content to "some text" 
set default_subject to "some subject"
tell theMessage
make new to recipient at end of to recipients with properties {address:default_address}
set subject to default_subject
set content to default_content
end tell
end tell

That should do it.

If you want to create the message that you’re going to send, it should look like:


Tell application "Mail"
--This assumes that the message you want to work with hasn't been created yet (e.g., you want to open a new outgoing message.)
set theMessage to (make new outgoing message at end of outgoing messages)
set default_address to "whatever@whatever.com" 
set default_content to "some text" 
set default_subject to "some subject"
tell theMessage
set visible to true
make new to recipient at end of to recipients with properties {address:default_address}
set subject to default_subject
set content to default_content
end tell
end tell

Hope this helps.