Hi folks, and nice to meet you all.
I am building a script in order to send my band newsletter to the subscribers. The script’s aim is to send an individual copy of the same message to each contact into a group in my adress book.
The script is (almost) working, and I’m doing some work to refine it…
The script is included in an AppleScript Studio project; I’ve made a cocoa window (InserisciTesto), where one inputs the tex of the message, with a button to start the script (that is theObject )
There are is a major problems, styled text…
My final aim is sending a newsletter with formatted text and attachments… But with this script the text I input gets converted in plain text… What should I do?
Here’s the code of the script:
-- Newsletter.applescript
-- Newsletter
--set NomiContatti to {}
on clicked theObject
set gruppi to {}
set InsiemeGruppi to {}
set IndirizziContatti to {}
set theSubject to "prova"
set theBody to content of text view "typedtext" in scroll view "scroll" in window "inserisciTesto" as styled text
--Sceglie il gruppo a cui inviare la newsletter tra i gruppi dell'address book
set InsiemeGruppi to {}
tell application "Address Book"
set gruppi to every group
repeat with girup in gruppi
set InsiemeGruppi to InsiemeGruppi & (name of girup)
end repeat
set risultato to choose from list InsiemeGruppi with prompt "Scegli a che gruppo inviare la newsletter" without multiple selections allowed
if the result is not equal to false then set Destinatari to risultato
display dialog (Destinatari)
end tell
tell application "Address Book"
set contatti to every person in group "Prova"
repeat with tizio in contatti
--set NomiContatti to NomiContatti & (get the name of tizio)
try
set IndirizziContatti to IndirizziContatti & (value of first item of email of tizio)
end try
end repeat
end tell
--estrae da Mail i vari account per poi decidere quale scegliere come mittente
tell application "Mail"
set listOfSenders to {}
set everyAccount to every account
repeat with eachAccount in everyAccount
set everyEmailAddress to email addresses of eachAccount
if (everyEmailAddress is not equal to missing value) then
repeat with eachEmailAddress in everyEmailAddress
set listOfSenders to listOfSenders & {(full name of eachAccount & " <" & eachEmailAddress & ">") as string}
end repeat
end if
end repeat
end tell
-- Prompt the user to select which account to send this message from.
set theResult to choose from list listOfSenders with prompt ¬
"Which account would you like to send this message from?" without multiple selections allowed
if theResult is not equal to false then
set theSender to item 1 of theResult
tell application "Mail"
--crea il nuovo messaggio
repeat with indirizzo in IndirizziContatti
set newMessage to make new outgoing message with properties {sender:theSender, subject:theSubject, content:theBody & return & return}
tell newMessage
set visible to true
make new to recipient at the end of to recipients with properties {address:indirizzo}
end tell
send newMessage
end repeat
activate
end tell
end if
-- Created by Tevac on Wed Oct 27 2004.
-- Copyright (c) 2003 __MyCompanyName__. All rights reserved.
end clicked
Thanks in advance for any help,
Davide