Slow "set color of" content in Apple Mail since Ventura

Hello everyone,
Since the installation of macOS Ventura 13.2, changing color in the message bodies is very very slow.
An extract from my script, which worked perfectly until now :

set x to offset of aParagraph in the_content
set color of characters x thru (x + (count of aParagraph)) of content to {0, 0, 0}

Has anyone experienced the same issue ?

Here is an example script, can someone try it ?


set the_subject to "Ed quossum enihil maion cumet dolorer ferspit"
set theTextToChange to "sequi ditas vellatum volupta tiorpos amendae magnatatiis exerisi nctiscieni sus, et poresec tatiate mporror aut pro que dissiti cor sum esecab imus magnisi volupta tinciissi invendae andae excestis ex et elitas dolupta et, sunti dolupta apienia dipsam aut a ius velessunt od quam, iliquistem int lam ini imus ra quatur sed quam erunt que quiatis ad essum alignam faciet et audae ommo que qui offici totatur erovitia voluptati non re precupis miliqui tor adis iliquia tisque int et autaquatque eaquas prepratis modigendit occullaut expeliqui te molorepedis experion cumendandam velit anihiciet explis corestrum volorectur si utem rempore mporit fuga."


set the_content to "Samusa aute delectu ribusae. Ed quossum enihil maion cumet dolorer ferspit quatur magnihi llandit por alit rempora temporectem num hit qui ut volorei caecupitin ped etus, volora volut molupic iaessimi, ommodit et ero tempe verchicatet ide samusam enistotae. Nam, sam in poribus ex etur, " & theTextToChange

tell application "Mail"
	activate
	set newEmail to make new outgoing message with properties {subject:the_subject, content:the_content}
	
	tell newEmail
		set x to offset of theTextToChange in the_content
		set font of characters x thru (x + (count of theTextToChange)) of content to "Helvetica Bold"
		set color of characters x thru (x + (count of theTextToChange)) of content to {56342, 2442, 607}
	end tell
	
end tell

You can literally see the script color each letter, so let’s just say it’s slow…

However, this :

		set color of content to {56342, 2442, 607}
		set font of content to "Helvetica Bold"

… is very fast, but obviously it changes font and color of the whole body.

Using words :

		set font of words 20 thru 30 of content to "Helvetica Bold"

is a lot faster, and using paragraph also…

Is there a workaround ?

alitaliano. FWIW, I tried your script on my Ventura computer and got the same result–it was very slow with individual characters being changed one by one. I also tried words of content, which was relatively slow, and paragraphs of content, which was fast (as you note). Sorry, but I don’t know of a workaround :frowning:

  1. Activating the application is optional, as bringing Mail.app to the foreground consumes time. It is better not to activate, but to run the application in the background while the rich text is processed letter by letter.

  2. Each additional open window of outgoing messages consumes more and more time, so it is better to close the previous windows.

  3. It’s better to block application responses while the rich text is being processed letter by letter.

Considering these 3 factors, I can increase the speed of your script by almost 2.5 times:
.

set the_subject to "Ed quossum enihil maion cumet dolorer ferspit"
set theTextToChange to "sequi ditas vellatum volupta tiorpos amendae magnatatiis exerisi nctiscieni sus, et poresec tatiate mporror aut pro que dissiti cor sum esecab imus magnisi volupta tinciissi invendae andae excestis ex et elitas dolupta et, sunti dolupta apienia dipsam aut a ius velessunt od quam, iliquistem int lam ini imus ra quatur sed quam erunt que quiatis ad essum alignam faciet et audae ommo que qui offici totatur erovitia voluptati non re precupis miliqui tor adis iliquia tisque int et autaquatque eaquas prepratis modigendit occullaut expeliqui te molorepedis experion cumendandam velit anihiciet explis corestrum volorectur si utem rempore mporit fuga."

set the_content to "Samusa aute delectu ribusae. Ed quossum enihil maion cumet dolorer ferspit quatur magnihi llandit por alit rempora temporectem num hit qui ut volorei caecupitin ped etus, volora volut molupic iaessimi, ommodit et ero tempe verchicatet ide samusam enistotae. Nam, sam in poribus ex etur, " & theTextToChange
set x to offset of theTextToChange in the_content
set y to x + (count of theTextToChange) - 1

tell application id "com.apple.mail"
	launch
	close outgoing messages saving no
	set newEmail to make new outgoing message with properties {subject:the_subject, content:the_content}
	ignoring application responses
		tell (content of newEmail) to tell (characters x thru y)
			set font to "Helvetica Bold"
			set color to {56342, 2442, 607}
		end tell
	end ignoring
end tell

Thanks a lot for your answers, I guess I’ll stick with the paragraphs approach…

1 Like