hi all,
I have this situation and really need help!
-an Adress Book group “Adresses” with 99 adresses, one entry field carries the appropriate adress i.e. ‘Dear Mr. Miller’ and ‘Dear Ms. Soso’
-A Folder with 99 subfolders containing 4 .pdf’s each, one always different, three the same -
-I need Mail to send out the emails with each adress receiving the 4 pdf’s form the corresponding subfolder, with the standardized subjectline and text, BUT with a specified Adress i.e. “Dear Mr. Miller…”
-I made a code that matches the right folders to the right adresses but only manages to upload one file as attachment when automatically creating an email with Mail, not all four. below you see my efforts to bring in all four files:
PHP-Code:
with timeout of 600 seconds --
-- List 1: All attachments
tell application "Finder"
set mailing to selection
set myFolders to every folder of (mailing as alias list)
set myFiles to every item of myFolders i
end tell
-- List 2: All recipients
tell application "Contacts"
set emailList to {}
set testPersons to every person of group "Adresses"
repeat with thisTestPerson in testPersons
set end of emailList to (value of email of thisTestPerson) as string
end repeat
end tell
-- List for matching: puts adresses in alphabetical order
set the_list to emailList
set otid to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10} -- always a linefeed
set list_string to (the_list as string)
set new_string to do shell script "echo " & quoted form of list_string & " | sort -f"
set new_list to (paragraphs of new_string)
set AppleScript's text item delimiters to otid
-- Double-Check: lengths of the two lists
set count1 to count of myFolders
set count2 to count of new_list
if count1 is not equal to count2 then
display dialog "There is a problem:" & return & "Die beiden Listen sind nicht gleich lang..." buttons {"Shit"} with icon 2
return
end if
-- creates and sends mass mailing:
tell application "Mail"
activate
repeat with i from 1 to count1
set theFiles to every file of (item i of myFolders) as alias
set theAddress to (item i of emailList)
set theMex to (make new outgoing message at end of outgoing messages with properties {visible:true, subject:"mailing", content:"Bitte entnehmen Sie dem Anhang ....."})
tell content of theMex
make new attachment with properties {file name:theFiles} at after last paragraph
end tell
tell theMex
make new to recipient at end of to recipients with properties {address:theAddress}
end tell
send theMex
end repeat
end tell
display dialog (count1 as string) & " Nachrichten verschickt."
end timeout
so, what I need now for this code to do is: 1) have the right form of adress (Dear Mr. Miller) in each email body 2) manage to get all 4 pdf’s attached to the mails
so I guess the first and the last part of the code need some working on, but I have not found out how to organize the subfolders as reference list for the adresses and get into the subfolders for picking out the right attachments. I also do not know how to implement the specific field I created in adressbook as a proper form of adress into the body.
thanks yo much for every little hint!