Make a single line of text bold in Mail message using Automator?
I have an automator script that creates a new email using the Mail app.
In this message, I would like a single line in bold as seen here:
on run {input, parameters}
set clipContent to (the clipboard as text)
tell application "Mail"
set myMessage to make new outgoing message at the beginning of outgoing messages with properties {subject:"subject"}
tell myMessage to make new to recipient at beginning of to recipients with properties {address:"[email protected]"}
set myMessage's content to "
Line of text
" & clipContent & "
Line of text <---- I want this line in **BOLD**
Regards,
Name"
return input
end run
Solution 1:
The following example AppleScript code is one way of achieving your goal:
set clipContent to (the clipboard as text)
set lineOfBoldText to "Line of text <---- I want this line in **BOLD**"
set myContent to linefeed & "Line of text" & linefeed & linefeed & ¬
clipContent & linefeed & linefeed & linefeed & lineOfBoldText & ¬
linefeed & linefeed & linefeed & "Regards," & linefeed & "Name"
set x to offset of lineOfBoldText in myContent
set y to x + (length of lineOfBoldText)
tell application "Mail"
set myMessage to make new outgoing message at ¬
the end of outgoing messages with properties ¬
{subject:"subject", content:myContent}
tell myMessage
make new to recipient at ¬
end of to recipients with properties ¬
{address:"[email protected]"}
set font of characters x thru y to "Helvetica Bold"
end tell
end tell
Having copied to the clipboard "In this message, I would like a single line in bold as seen here:" from your OP and run the example AppleScript code, shown in my answer, in Script Editor, here is a screen shot of the results: