Retreiving Mail message from id

This is a question about Mail and how to script it.

The background is that I’m using Excel 2004 to handle a data base of workers and am automating parts of the data entry. Specificaly, getting e-mail addresses and other information directly from emails received in Mail.

Currently the “flow” is

Excel VBA - Create a userform

AppleScript (via VBA MacScript command)

tell application "Mail"
	return {id, sender, subject} of messages in inbox
end tell

Excel VBA-
Parse that data and fill a list box.
User selects a message.
VBA reads the id of the user selected message and creates/runs:

Applescript

tell application "Mail"
	repeat with oneMessage in messages in inbox
		if id of oneMessage = 3596 then return content of oneMessage
	end repeat
	return ""
end tell

This works well enough, but I don’t like looping in that second script.
I’ve tried syntax that fails like

-- won't compile 
return content of (message id 3596 of mailbox "INBOX" of account "Yahoo" of application "Mail")

My question is, given the id of a Mail message (“The unique identifier of the message.”) is there a syntax to return the content of that message without looping?

Thanks.

Hi,

try this


tell application "Mail"
	try
		return content of (get 1st message of inbox whose id is 3596)
	on error
		return ""
	end try
end tell

Sweet!

Thank you!!