Scripting Mail.app port number

I am trying to use applescript to set a port in Mail (Mac OS X 10.2.3).

The following code produces the error “NSCannotCreateScriptCommandError”

property theAccount : "accountname"

tell application “Mail”
set everyAccount to every account
repeat with eachAccount in everyAccount
if (name of eachAccount is equal to theAccount as string) then
set port of eachAccount to 1240
end if
end repeat
end tell
</applescript code>

I have looked at Mail’s dictionary and found
“port - integer - The port used to connect to an account”

Changing the above code to
“set empty junk messages frequency of eachAccount to 0”
does not produce any error even though it is also an integer…
“empty junk messages frequency - integer - Number of days before archived sent messages are deleted (0 = never delete, -1 = delete on quit)”

I’m stumped, Can anyone offer any advice?

I read that there’s an error in Mail’s dictionary for ‘port’ (Apple has been notified). What happens if you change this

set port of eachAccount to 1240 

to this

set server port of eachAccount to 1240

It works :smiley:

Thanks!