Extract info from message in Mail.app

Example of extracting information from a selected email in Apple’s Mail.app. There are many more if you look in the dictionary of Mail.

OS version: OS X

tell application "Mail"
	set theSelectedMessage to selection
	if (count of theSelectedMessage) is equal to 0 then
		display dialog "Please select a message in Mail first, then run this script again."
	else if (count of theSelectedMessage) is equal to 1 then
		set thisMessage to item 1 of theSelectedMessage
		set theBody to content of thisMessage
		set theTargetText to paragraph 3 of theBody
		set theSource to source of thisMessage
		set theSubject to subject of thisMessage
		set theSender to sender of thisMessage
		set theId to message id of thisMessage
		set theSize to message size of thisMessage
	else
		display dialog "Please select only one message in Mail first, then run this script again."
	end if
end tell

First off many thanks for this entry it’s awesome!
I’m trying to create an automated blog from scratch. The part I’m missing is getting the name of the attachment of the photo sent with the email. (The user sends an email it’s uploaded to the server and the necessary text is added to display the image.)

Can you force the latest email received to be selected?