I have a script that automatically attaches an FTP link to an email
and uses
the name of the file to determine who should get the email.
My challenge is I want to have one creation step with the variables
changing
depending on the receiving location. I could use variables to set the
name
and address but each location gets different number of recipients so
that
doesn't work.
I have created a variable that consists of a string that mimics the
hard
coded. Here is the hard code.
Tell new message
Set content of it to the_body
Make new to recipient at end with properties {name: "Jane Doe",
address:
"email@hidden"}
Make new to recipent at end with properties {name: "John Roe", address:
"email@hidden"}
End tell
so I did
Set myRecips to "Make new to recipient at end with properties {name:
\"Jane
Doe\", address: \"email@hidden\"}
Make new to recipent at end with properties {name: \"John Roe\",
address:
\"email@hidden\"}"
Then tried
Tell new message
Set content of it to the_body
myRecips
End tell
-----
The variable matches the command but I guess I need some kind of
statement
or such that says treat this string as a line of code and I can't
find a
way to do it
You won't find a way to do that. Try something like this:
set newMsg to make new outgoing message
set the_body to "hello world"
set myRecips to {{name:"Jane Doe", address:"email@hidden"},
{name:"John Roe", address:"email@hidden"}}
tell newMsg
set content of it to the_body
repeat with i from 1 to length of myRecips
make new to recipient at end with properties item i of myRecips
end repeat
end tell
set visible of newMsg to true -- check to see if it is working