Application Mail - New Message - Bold Body Text In Color !

Hello Everyone,

I am trying to automate my email creation and need a little help with stylizing body text in the application Mail. In the script below I need just the job number “0293” to be the color green and bold font.


tell application "Mail"
	activate
	set newEmail to make new outgoing message with properties {subject:"Job Number", content:"Job Number: 0293"}
	tell newEmail
		set visible to true
		make new to recipient at end of to recipients with properties {address:"address1@address.com"}
		make new cc recipient at end of cc recipients with properties {address:"address2@address.com"}
	end tell
end tell

Any help would be greatly appreciated,
CarbonQuark

Hi,

Something like:

tell application "Mail"
	activate
	set newEmail to make new outgoing message with properties {subject:"Job Number", content:"Job Number: 0293"}
	tell newEmail
		set visible to true
		make new to recipient at end of to recipients with properties {address:"address1@address.com"}
		make new cc recipient at end of cc recipients with properties {address:"address2@address.com"}
		set color of word -1 of content to {0, 32896, 16448}
		set font of word -1 of content to "Helvetica Bold"
	end tell
end tell

If you don’t like the colour you could choose another:

choose color

You can set font, color and size of the font.

Best wishes

John M

John M,

You are the man!

I tried for many hours to get this to work. I can’t tell you how much I appreciate your help. This forum has always been a great place and it’s because of people like you.

Thanks,
CarbonQuark

Thanks for this, but I’ve expanded it.

For Posterity…


set theSenderTemp to "valid_email_address"
set the_mailto to "valid_email_address"
set PrintDateTimeName to "2007-07-09 123456Z"
set TheName to "07 Corporate Brochure cover emboss lines.qxp"

set the_subject to "Alert! Order printing problem."
set the_content to ("G'day" & return & return & "This is an automated message from Universal Widgets Inc.." & return & return & "An item that could not be printed has been encountered while preparing an email Order for printing." & return & return & "The Order email for the item is from " & theSenderTemp & "." & return & return & "The item, " & TheName as text) & ", from the folder '" & PrintDateTimeName & "' has been re-located into the folder 'Unrecognized items for Manual Printing'." & return & return & "Please note that a cover sheet should have been printed, as well as any other printable items from this folder."
tell application "Mail"
	activate
	
	set newMessage to make new outgoing message with properties {address:the_mailto, subject:the_subject, content:the_content}
	tell newMessage
		set x to offset of "Universal Widgets Inc.." in the_content
		repeat with y from 0 to count of "Universal Widgets Inc.."
			set font of character (x + y) of content to "Helvetica Bold"
			set color of character (x + y) of content to {48632, 1630, 1102}
		end repeat
		set x to offset of TheName in the_content
		repeat with y from 0 to count of TheName
			set font of character (x + y) of content to "Helvetica Bold"
		end repeat
		set x to offset of PrintDateTimeName in the_content
		repeat with y from 0 to count of PrintDateTimeName
			set font of character (x + y) of content to "Helvetica Bold"
		end repeat
		set x to offset of "'Unrecognized items for Manual Printing'." in the_content
		repeat with y from 0 to count of "'Unrecognized items for Manual Printing'."
			set font of character (x + y) of content to "Helvetica Bold"
		end repeat
		make new to recipient with properties {address:the_mailto}
		send
	end tell
end tell

Actually, this is a lot faster


set x to offset of "Universal Widgets Inc.." in the_content
					set font of characters x thru (x + (count of "Universal Widgets Inc..")) of content to "Helvetica Bold"
					set color of characters x thru (x + (count of "Universal Widgets Inc..")) of content to {56342, 2442, 607}
					set x to offset of TheName in the_content
					set font of characters x thru (x + (count of TheName)) of content to "Helvetica Bold"
					set x to offset of PrintDateTimeName in the_content
					set font of characters x thru (x + (count of PrintDateTimeName)) of content to "Helvetica Bold"
					set x to offset of "'Unrecognized items for Manual Printing'." in the_content
					set font of characters x thru (x + (count of "'Unrecognized items for Manual Printing'.")) of content to "Helvetica Bold"
					

Santa,

Unfortunately, your code isn’t compatible with 10.7 causes an error but John M works still.

change this

set newMessage to make new outgoing message with properties {address:the_mailto, subject:the_subject, content:the_content}

to

set newMessage to make new outgoing message with properties {subject:the_subject, content:the_content}

removed: address:the_mailto

to get it working in 10.7