Le 10/06/2015 à 10:28, Fred Diepeveen < email@hidden> a écrit :
Hi, I've some templates in mail. These are very handy when I need to send out a lot of emails with standard text/links/logo's etc. Can anybody help me how to select a template in applescript when creating a new mail message? I don't want to use signature.
Here is the piece of code I posted some hours ago in macScripter as an answer to a resembling question.
set MsgSender to "email@hidden" -- must be configured address, or will default (but still runs fine). set MsgRecipient to "email@hidden" -- changed this to valid recipient
tell application "Mail" set TheMessages to the selection -- this is a list repeat with current_Message in TheMessages -- individual message set fwd_Message to forward current_Message with opening window tell fwd_Message activate set sender to MsgSender set my_recipient to make new to recipient at end of to recipients with properties {address:MsgRecipient} my grabIt() end tell end repeat end tell
on grabIt() tell application "System Events" to tell process "Mail" set frontmost to true keystroke "a" using {command down} keystroke "x" using {command down} end tell delay 0.5 --set theDatas to the clipboard
tell application "TextEdit" activate set tEditDoc to make new document end tell tell application "System Events" to tell process "TextEdit" set frontmost to true keystroke "v" using {command down} end tell
tell application "TextEdit" to tell tEditDoc delete (paragraphs 1 thru 10) end tell set the clipboard to "" tell application "System Events" to tell process "TextEdit" set frontmost to true keystroke "a" using {command down} keystroke "c" using {command down} end tell delay 0.5 tell application "TextEdit" close tEditDoc without saving end tell
tell application "Mail" to activate
tell application "System Events" to tell process "Mail" set frontmost to true keystroke "a" using {command down} keystroke "v" using {command down} end tell
end grabIt
Yvan KOENIG (VALLAURIS, France) mercredi 10 juin 2015 21:55:05
|