以下是一个使用AppleScript在OSX邮件中将某些单词加粗的示例代码:
tell application "Mail"
set selectedMessages to selection
repeat with theMessage in selectedMessages
set messageContent to content of theMessage
set paragraphsList to paragraphs of messageContent
repeat with theParagraph in paragraphsList
set paragraphText to text of theParagraph
set firstThreeCharacters to text 1 thru 3 of paragraphText
if firstThreeCharacters is a number then
set boldWords to {}
set wordsList to words of theParagraph
repeat with theWord in wordsList
if theWord is "example" or theWord is "words" then
set end of boldWords to "" & theWord & ""
else
set end of boldWords to theWord
end if
end repeat
set newParagraphText to boldWords as string
set text of theParagraph to newParagraphText
end if
end repeat
end repeat
end tell
此示例代码会将选定的邮件消息中以三位数开头的段落中的"example"和"words"这两个单词加粗。你可以根据需要修改这两个单词,或添加其他需要加粗的单词。
请注意,此代码只会修改选定的邮件消息中的段落文本。如果你想要在所有邮件中运行此代码,请将set selectedMessages to selection
改为set selectedMessages to every message of inbox
。