I can’t guarantee that Mail behaves the same under Catalina but, under High Sierra it doesn’t behave as it did when StefanK wrote its script.
Under 10.13.6, the text field is no longer in a scroll area.
Below is an edited version.
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
-- set fixLocaleShort to current application's NSLocale's currentLocale()'s languageCode() as text
set liveLocaleShort to current application's NSLocale's autoupdatingCurrentLocale()'s languageCode() as text
set sys2 to (system attribute "sys2") as integer
tell application "Mail"
activate
set x to "fGb-Sh-fUL.title"
set loc to localized string x from table "ComposeWindowController"
if (loc = "fGb-Sh-fUL.title") and liveLocaleShort = "en" then
set loc to "Reply-To Address Field"
else if liveLocaleShort = "fr" then
set loc to "Champ Répondre à"
end if
set replyToAddressField_loc to loc
set x to "KG0-Fs-IxZ.title"
if sys2 < 15 then
set loc to localized string x from table "ComposeViewController"
else
set loc to localized string x from table "ComposeViewControllerWK2"
end if
if (loc = "KG0-Fs-IxZ.title") and (sys2 < 14) and liveLocaleShort = "en" then
set loc to "Reply To:" -- for 10.13.6
end if
set reply_loc to loc
set theRecipient to "<you@yourdomain.com>"
set theBCCRecipients to {"them1 <they1@theirdomain.com>", "them2 <they2@theirdomain.com>", "them3 <they3@theirdomain.com>"}
set theReplyToAddress to "NOREPLY@mydomain.com"
set theSendingAccount to "Me <me@mydomain.com>"
set theSubject to "This is the Subject"
set theMessage to "This is text for the body of the message."
set newMessage to (make new outgoing message with properties {visible:true, subject:theSubject, sender:theSendingAccount, content:theMessage})
tell application "System Events"
tell process "Mail"
tell menu item replyToAddressField_loc of menu 1 of menu bar item 5 of menu bar 1 -- EDITED
if value of attribute "AXMenuItemMarkChar" is "" then pick it -- if reply field is not enabled, enable it
end tell
set value of text field reply_loc of window 1 to theReplyToAddress -- EDITED
end tell
end tell
tell newMessage
make new to recipient at end of to recipients with properties {address:theRecipient}
repeat with i in theBCCRecipients
make new bcc recipient at end of bcc recipients with properties {address:i}
end repeat
end tell
end tell
You tried to use tags with the strings “code” and “/code” but on this site they are supposed to be “applescript” and “/applescript”
No need to type them by hand, just use the dedicated button, the one between “Quote” and “Center”.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 30 mai 2020 15:32:35
Edited because:
The wanted menu item “Reply-To Address Field” is no longer the one at index 9 but the one at index 13.
The field “Reply To:” is not guaranteed to be at index 3 (on my machine, it’s at index 4)
Added a script listing the localized versions of the string “Reply-To Address Field”
----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
-- Build an array of the localized strings for a given key
-- Yvan KOENIG (VALLAURIS, France) Samedi 30mai 2020
----------------------------------------------------------------
property |⌘| : a reference to current application
set theLanguages to paragraphs of "ar
ca
cs
da
de
el
en_AU
en_GB
en
es_419
es
fi
fr_CA
fr
he
hi
hr
hu
id
it
ja
ko
ms
nl
no
pl
pt_PT
pt
ro
ru
sk
sv
th
tr
uk
vi
zh_CN
zh_HK
zh_TW
Dutch
English
French
German
Italian
Japanese
Spanish"
set root to (path to application "Mail" as text) & "Contents:Resources:"-- EDITED, the app's location changed
set fullTable to "ComposeWindowController.strings"
set theKey to "fGb-Sh-fUL.title"
-- Now extract the value for every language available
set theArray to |⌘|'s NSMutableArray's new()
repeat with usedLanguage in theLanguages
set theFile to root & usedLanguage & ".lproj:" & fullTable
set anURL to (|⌘|'s NSURL's fileURLWithPath:(POSIX path of theFile))
set theDict to (|⌘|'s class "NSDictionary"'s dictionaryWithContentsOfURL:anURL)
if theDict is not missing value then
set theValue to (theDict's valueForKey:theKey) as string
else
set theValue to "????"
end if
(theArray's addObject:((usedLanguage as string) & tab & theValue))
end repeat
set theData to (theArray's componentsJoinedByString:linefeed)
-- save data to new file
set bareName to theKey & " locales"
set hfsPath to (path to desktop as text) & bareName & ".txt"
set targetFile to hfsPath as «class furl»
(theData's writeToURL:targetFile atomically:true encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value))
set wName to bareName & ".txt"
tell application "TextEdit"
activate
if exists window wName then close window wName
open targetFile
end tell
#=====
and what is returned under 10.13.6
ar حقل عنوان رد على
ca Camp d’adreça “Respondre a”
cs Pole Odpověď na
da Adressefeltet Svar til
de Adressfeld „Antwort an“
el Πεδίο διευθύνσεων απάντησης προς
en_AU ???
en_GB ???
en ???
es_419 Campo de dirección “Responder a”
es Campo de dirección “Responder a”
fi Vastaus-osoitekenttä
fr_CA ???
fr Champ Répondre à
he שדה כתובת ״כתובת למענה״
hi उत्तर-प्रति पता फ़ील्ड
hr Adresno polje odgovora
hu Válaszcímmező
id Bidang Alamat Balas-Ke
it Campo indirizzo Rispondi a
ja 返信先アドレス欄
ko 답장 받는 사람 주소 필드
ms Medan Alamat Balas Kepada
nl Antwoord aan-adresveld
no Svar til-adressefelt
pl Pole adresowe Odpowiedź do
pt_PT Campo Responder a
pt Campo de Endereço “Responder A”
ro Câmp de adresă Răspuns către
ru Поле «Обратный адрес»
sk Pole adresáta odpovede
sv Adressfältet Svara till
th ช่องที่อยู่ตอบกลับ
tr Yanıt Adresi Alanı
uk Поле «Кому відповісти»
vi Trường địa chỉ trả lời
zh_CN “回复至”地址栏
zh_HK ???
zh_TW 回覆給位址欄位
Dutch ???
English ???
French ???
German ???
Italian ???
Japanese ???
Spanish ???
If it’s ran under Mojave or Catalina it will return:
ar حقل عنوان رد على
ca Camp d’adreça “Respondre a”
cs Pole Odpověď na
da Adressefeltet Svar til
de Adressfeld „Antwort an“
el Πεδίο διευθύνσεων απάντησης προς
en_AU Reply-To Address Field
en_GB Reply-To Address Field
en ???
es_419 Campo de dirección “Responder a”
es Campo de dirección “Responder a”
fi Vastaus-osoitekenttä
fr_CA Champ Répondre à
fr Champ Répondre à
he שדה כתובת ״כתובת למענה״
hi जवाब-प्रति पता फ़ील्ड
hr Adresno polje odgovora
hu Válaszcímmező
id Bidang Alamat Balas-Ke
it Campo indirizzo Rispondi a
ja 返信先アドレス欄
ko 답장 받는 사람 주소 필드
ms Medan Alamat Balas-Kepada
nl Antwoord aan-adresveld
no Svar til-adressefelt
pl Pole adresowe Odpowiedź do
pt_PT Campo Responder a
pt Campo de Endereço “Responder A”
ro Câmp de adresă Răspuns către
ru Поле «Обратный адрес»
sk Pole adresáta odpovede
sv Adressfältet Svara till
th ช่องที่อยู่ตอบกลับ
tr Yanıt Adresi Alanı
uk Поле «Кому відповісти»
vi Trường địa chỉ trả lời
zh_CN “回复至”地址栏
zh_HK 回覆地址欄位
zh_TW 回覆給地址欄位
Dutch ???
English ???
French ???
German ???
Italian ???
Japanese ???
Spanish ???
Edited the first script because Catalina doesn’t use the same table than older systems