Re: Re(2): PowerMail: Sending and CCing to Messrs Foo & Bar
Re: Re(2): PowerMail: Sending and CCing to Messrs Foo & Bar
- Subject: Re: Re(2): PowerMail: Sending and CCing to Messrs Foo & Bar
- From: Nigel Garvey <email@hidden>
- Date: Wed, 17 Apr 2013 23:21:46 +0100
JF wrote on Tue, 16 Apr 2013 21:41:25 +0100:
>Thank you. I prefer the first version you sent because, at this stage
of my
>amateur status, I like to see the steps on different lines.
Yes I saw that. I posted the second version because in my earlier post,
I'd said that recipients _have_ to be created separately, which isn't
actually true. Since it was my first post to this list for a couple of
months and yours was the first query here about PowerMail for almost
exactly five years, I wanted to get it right. ;)
What I said about recipients being elements (things) — not properties
(values) — in a PowerMail message is true, and for the most part they
have to be scripted as such. However, when a message is 'made',
PowerMail allows a list of recipients to be given as the value of a
'recipient' property in the 'with properties' record. I think this is a
trick copied from Claris Emailer. The message itself doesn't itself have
a 'recipient' property, only the 'with properties' record does.
The demo script with which you were experimenting, which comes with
PowerMail, shows off the numerous ways recipients can be specified for
creation — except, unbelievably, as elements! The following script shows
three different ways that 'to' recipients can be specified when added as
elements to an already existing PowerMail message:
tell application "PowerMail"
activate
set msg to (make new message with properties {subject:"'make' new recipients (element syntax)"})
make new recipient at msg with properties {recipient type:to recipient, address:{display name:"Aardvark Tannhäuser", email address:"email@hidden"}}
make new recipient at msg with properties {recipient type:to recipient, address:"Anton Tannhäuser <email@hidden>"}
make new recipient at msg with data "Adolph Tannhäuser <email@hidden>"
-- A recipient can also be made 'of' a message instead of 'at' it.
-- A recipient's 'recipient type' defaults to 'to recipient' if not specified.
-- The display name can be omitted in any of the above.
-- The e-mail address can be in angle brackets or not in any of the above.
end tell
When creating the recipients along with the message, the possible
permutations become ridiculous. The value of 'recipient' in the 'with
properties' record can be:
A list of records, each record specifying a recipient.
A list of strings, ditto.
A list containing a mixture of records and strings.
Additionally, any string in the list may contain comma-delimited
specifiers for more than one recipient. It's also possible to have a
string instead of a list as the value of the 'recipient' property. The
three message creation commands below show some of the possibilities:
tell application "PowerMail"
activate
set msg to (make new message with properties {subject:"'recipient' property as list", recipient:{{recipient type:to recipient, address:{display name:"Aardvark Tannhäuser", email address:"email@hidden"}}, {recipient type:to recipient, address:"Anton Tannhäuser <email@hidden>"}, "Adolph Tannhäuser <email@hidden>"}})
set msg to (make new message with properties {subject:"'recipient' property as text", recipient:"Aardvark Tannhäuser <email@hidden>, Anton Tannhäuser <email@hidden>, Adolph Tannhäuser <email@hidden>"})
set msg to (make new message with properties {subject:"'recipient' property as list, including multiple-recipient text", recipient:{{recipient type:to recipient, address:{display name:"Aardvark Tannhäuser", email address:"email@hidden"}}, "Anton Tannhäuser <email@hidden>, Adolph Tannhäuser <email@hidden>", {recipient type:cc recipient, address:{display name:"Aloysius Tannhäuser <email@hidden>"}}}})
end tell
>But I have realised that one of my mistakes when trying to do this
myself I
>had four right braces, which Script Debugger accepted for compilation,
when
>it should have been three right braces and a bracket. }}}). I wonder
why SD
>did not pick that up.
The fewer right braces were because I corrected your overall
list-of-records structure. The three braces then became, from left to
right, the end of the record for the second recipient, the end of the
'recipient' list containing the recipients, and the end of the 'with
properties' record. The bracket matches the the left bracket I inserted
before 'make' because I like to put commands in parenthesis when setting
variables to their results.
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden