RTF als Email-Formatvorlage
23/03/2011Hey REPLACEME1,
how you are doing. Do you have time for REPLACEME2?
Yours REPLACEME3
set mytemplate to choose file
set replace_list to {"my friend", "what ever", "hubionmac"}
set replace_markers to {}
repeat with i from 1 to count of replace_list
set replace_markers to replace_markers & {"REPLACEME" & i}
end repeat
tell application "TextEdit"
set mytextfile to open mytemplate
set mytext_parts to attribute run of mytextfile
set mylayout to properties of attribute run of mytextfile
close mytextfile
end tell
repeat with i from 1 to count of replace_list
repeat with k from 1 to count of mytext_parts
set item k of mytext_parts to my replace_chars(item k of mytext_parts as text, item i of replace_markers as text, item i of replace_list as text)
end repeat
end repeat
set mytext to mytext_parts as text
tell application "Mail"
activate
set myMessageText to make new outgoing message with properties {content:mytext, visible:true}
tell myMessageText
set globalcounter to 1
set pointer to 1
repeat with i from 1 to count of mytext_parts
set currentcount to count of every character of item i of mytext_parts
set font of characters globalcounter through (globalcounter + currentcount - 1) to (font of item i of mylayout)
set size of characters globalcounter through (globalcounter + currentcount - 1) to (size of item i of mylayout)
set color of characters globalcounter through (globalcounter + currentcount - 1) to (color of item i of mylayout)
set globalcounter to globalcounter + currentcount
end repeat
(**
--this does not work 100% since set word i does not wait for the command to finish
repeat with i from 1 to count of every word
set myword to word i
if myword is in replace_markers then
set word i to (item ((characters 14 through -1 of (myword as text)) as text as integer) of replace_list) as text
end if
end repeat**)
end tell
end tell
on replace_chars(this_text, search_string, replacement_string)
if this_text contains the search_string then
set od to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to od
end if
return this_text
end replace_chars
Ich habe in letzter Zeit etwas mit JavaScript-Befehlen in Safari herumgespielt. Dabei bin ich dann auch auf die Idee gekommen mal die Fenster darüber zu verschieben und in der Größe zu verändern.Am Ende ist es doch aber recht dumm, wenn man über irgendwelche Formeln Fenster genau aufteilt, jeder hat da seine eigene praktische Anordnung, warum also diese nicht einmal einrichten und dann immer wieder aufrufen können.Das Skript kommt nun also vollkommen ohne Java-Script aus und funktioniert wie folgt: