Notes app: Create new note with formatted title?

I have a script to create new notes in the Notes app, and I’m wanting to format the title/first line. I’ve tried a few things but am struggling with it.

Here’s the script:

set noteTitle to "Test Note 1"
set noteBody to "Blah, blah, blah"


tell application "Notes"
	activate
	tell account "iCloud"
		tell folder "Notes"
			make new note with properties {name:noteTitle, body:noteBody}
		end tell
	end tell
end tell

I have ‘New notes start with: Title’ checked in Notes’ Preferences, but that doesn’t seem to affect notes created with AppleScript.

I don’t want to change any of the text (title or body) with a different font or anything. All I want to do is format the first line as title (as though I’ve highlighted the first line and then selected ‘Format > Title’ from the menu bar (or toolbar)".

Any help would be greatly appreciated.


set noteBody to "<body><h1 style=”color:white;”>Test Note 1</h1>
<p style=”color:red;” >Blah, blah, blah</p>
</body>"

tell application "Notes"
	activate
	tell default account to tell folder "Notes"
		make new note with properties {name:" ", body:noteBody}
	end tell
end tell

Nice!
Thanks KniazidisR!

:cool: But change the smart quotes () to escaped quotes (")!

I see the color …


Why?
It worked perfectly for me. Am I missing something ? (I am sure I am…)
:frowning:

Yes, you are right, Nigel. Update script above (to get correct color’s behavior):


set noteBody to "<body><h1 style=\"color:green;\">Test Note 1</h1>
<p style=\"color:red;\" >Blah, blah, blah</p>
</body>"

tell application "Notes"
	activate
	tell default account to tell folder "Notes"
		make new note with properties {name:" ", body:noteBody}
	end tell
end tell

That’s great, thanks a lot!