grabbing HTML email produces "????????"

Hi, I am trying to capture the text of a paypal email within mail.app using:

tell application "Mail"
	set theseMessages to selection
	set thisMessage to item 1 of theseMessages
	set myText to (content of thisMessage) as text
end tell

however, the result since the paypal email is HTML mail, myText becomes “???”

and thats it…

Does anyone have any suggestions on how I can convert HTML email to standard text for the purposes of this capture?

-patrick

Hi Patrick,

Try this after selecting your message:

tell application "Mail"
	set theseMessages to selection
	set thisMessage to item 1 of theseMessages
	set myContentType to content of header "content-type" of thisMessage
	set mySource to source of thisMessage
end tell

if myContentType begins with "multipart/alternative" or myContentType begins with "multipart/related" then
	-- problems with nested multipart types
	set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"boundary="}}
	set myBoundry to (text item 2 of myContentType) as text
	set AppleScript's text item delimiters to {"\""}
	set myBoundry to (text items of myBoundry) as text
	set AppleScript's text item delimiters to {"text/plain;"}
	set myText to text item 2 of mySource
	set AppleScript's text item delimiters to {myBoundry}
	set myText to text item 1 of myText
	set AppleScript's text item delimiters to myTID
end if
myText

John M