Use default signature in new Mail message

Is it possible to use the default signature (if one has been setup) in a new message without knowing it’s name? Or is it possible to retrieve the name of the default signature for use in setting the properties of a new message.

My script is:


tell application "Mail"
	set strSUBJ to "mySubject"
	set strCONTENT to "myContent"
	set newMessage to make new outgoing message with properties {subject:strSUBJ, content:strCONTENT, visible:true}
	set message signature of newMessage to signature "Signature #2"
	tell newMessage
		make new to recipient at end of to recipients with properties {name:"myName", address:"myAddress"}
	end tell
	activate
end tell

Not all my users will have a signature named Signature #2 and those that do may use another as their default. I need the script to be able to use the default signature, if there is one.

TIA!

Wow! It’s not as straightforward as it sounds.

In Mail 4.5, it appears that the default signature is placed in the content of the message anyway, but is immediately overwritten by the specification in the script that the content shoud be ‘strCONTENT’.

The obvious thing to do would be not to specify the content in the ‘with properties’ record, but to make the message without it, get the content (ie. the text of the signature), concatenate that to ‘strCONTENT’, and then set the content to the result. But that doesn’t change the content (on my machine).

I’ve had some success with the following two methods, the second producing the better looking result and more quickly. However, I don’t understand why it works at all when the “obvious” method above doesn’t. :confused:


tell application "Mail"
	set strSUBJ to "mySubject"
	set strCONTENT to "myContent"
	set newMessage to (make new outgoing message with properties {subject:strSUBJ, visible:true})
	make new paragraph at beginning of content of newMessage with data strCONTENT
end tell


tell application "Mail"
	set strSUBJ to "mySubject"
	set strCONTENT to "myContent"
	set newMessage to (make new outgoing message with properties {subject:strSUBJ, visible:true})
	set defaultSig to newMessage's message signature
	set content of newMessage to strCONTENT
	set message signature of newMessage to defaultSig
end tell

Nigel- creative solution. I was starting to head down mining the signature out of the plist so I like your solution much more. Also works with Mail 5 on Lion. Many thanks!!!