The script below is a modified version because the original version is more time consuming when it comes to testing the script.
set friendslist to {"a", "Mi", "am", "self"}
set chose_friends to (choose from list friendslist with prompt "Friend(s) to send email to:" with multiple selections allowed)
set thefriend to the result
if thefriend contains {"Mi"} then
set theAddress to "Mi10@gmail.com"
my sendemail(thefriend, theAddress)
end if
if thefriend contains {"am"} then
set theAddress to "sf@gmail.com"
my sendemail(thefriend, theAddress)
end if
if thefriend contains {"self"} then
set theAddress to "bn@gmail.com"
my sendemail(thefriend, theAddress)
end if
if thefriend contains {"a"} then
set theAddress to "aue@gmail.com"
my sendemail(thefriend, theAddress)
end if
on sendemail(thefriend, theAddress)
set theName to thefriend
set theName to theName as text
display dialog theName & return & theAddress
end sendemail
Question 1:
I am going to add more friends to this list.
I want to avoid writing the “if” statements four times and improve this script so that
–it works faster
–more friends can be added easily without having to make many changes at different places in the script
Question 2:
When I select multiple friends in the prompt (dialog box), separate emails are sent. I would like to send one email using “Bcc”(which hides the other receipients from the receiver of the email). I am unable to modify the script to make use of “Bcc” .
Please help.