make a list out of strings (with of-statements)

Hi,

I know how to get a list like:
set groceryList to {“eggs”, “milk”, “bread”}

output: {“eggs”, “milk”, “bread”}

now what is the difference between this list, where the elements are separated by a comma and this list you get from mail (with the selected messages command):

{message id 180382 of mailbox “Inbox” of account “GoogleMail” of application “Mail”}

And how can I make this kind of list (with the of-statements) out of strings?

I have “Inbox”, “180382”, “GoogleMail” as plain strings. How can I connect them to this type of list?

thanks!

Hi,

the list of Mail.app contains one or multiple references to the selected message(s)

account is an element (class) of application Mail
mailbox is an element of class account
message is an element of class maibox

“Inbox”, “180382”, “GoogleMail” are specifiers to identify a single element

Hi thanks!

That makes me understand this list.

But is there actually a way to construct this kind of “object” with strings?

So if I the informations as strings like this:


set x1 to "GoogleMail"
set x2 to "Sent Messages"
set x3 to 180603
set x3 to "Inbox"

or do I have to use statements like
“select account x1”
“select mailbox x2”
“select inbox”
“select message x3”

edit:

I just tried:


tell application "Mail"
	set selected messages of message viewer 1 to message 1 of mailbox "Sent Messages" of account "GoogleMail" of application "Mail"
end tell

but I get an error (“AppleEvent Handler failed”)

This also doesn’t work:


tell application "Mail"
	set selected messages of message viewer 1 to {message id 180411 of mailbox "Sent Message" of account "GoogleMail" of application "Mail"}
end tell

something like this


set accountSpecifier to "GoogleMail"
set mailBoxSpecifier to "Sent Messages"
set messageIDSpecifier to 180603
tell application "Mail"
	try
		set selectedMessage to 1st message of mailbox mailBoxSpecifier of account accountSpecifier whose id is messageIDSpecifier
	on error
		display dialog "message " & messageIDSpecifier & "not found"
	end try
end tell


Thanks!

this works fine … but only if I the mailbox is already selected:

set accountSpecifier to "GoogleMail"
set mailBoxSpecifier to "INBOX"
set messageIDSpecifier to 178754


tell application "Mail"
	activate
	if (count of message viewers) is 0 then
		make new message viewer at front
	end if
end tell

tell application "Mail"
	try
		set selectedMessage to 1st message of mailbox mailBoxSpecifier of account accountSpecifier whose id is messageIDSpecifier
	on error
		display dialog "message " & messageIDSpecifier & "not found"
	end try
end tell


tell application "Mail"
	set selected messages of message viewer 1 to {selectedMessage}
end tell

So it selects the correct email if and only if I am already in the correct mailbox.

Is there a way to first change the mailbox to “GoogleMail” / “Inbox”
and then change the selected email with “set selected message”?