Hi,
I am asking the community here for some help.
I have been making little Applescripts for my personal use for a while now, even made a small little App in Facespan a few years ago, so I am not a complete beginner, but I can’t solve this problem:
The Task:
I have to email large images (>1mb) quite frequently. Since it is a “no-no” to email 10 of them at once I send them one by one. Doing so is somewhat cumbersome if you have to enter the information one by one. Furthermore I wanted to add the byline “,1 of 10” etc in the subject line, to give the recipient some clue how much is coming or if he/she is still missing some emails. I played with Automator but didn’t get a completely satisfactory result. I made a little Applescript droplet, that lets me enter a recipient, a subject line (adding the file count) and then lets me choose if I want to send the emails right away or just save them for later.
The Problem:
The functionality is all there but now I would like to interact with my addressbook and choose a recipient from it, a slicker, and less error proof method. How can I solve that?
(below is the script as it is right now)
Any thoughts and help is greatly appreciated!
thanks, Rainer
(*
Rainerstudio email send droplet. Sends an email for each files dropped onto it. Takeing the custom subjet line and adding a count ", 1 of 10" etc. to it.
*)
on run
display dialog "Please drag files on me..." buttons {"OK"} default button "OK"
end run
on open theFolders
-- count the files
set the item_count to the number of items in the theFolders as string
set theCountdown to item_count
-- enter the subject
display dialog "Please Enter a Subject:" default answer ""
set theSubject to text returned of result
-- set the recipient
display dialog "Please Enter a recipient:" default answer ""
set recipAddress to text returned of result
-- save or send
display dialog "What do you want to do mit the mails? Save or Send" buttons {"Send", "Save"} default button "Save" with icon caution
if button returned of result = "Save" then
-- save
repeat with eachitem in theFolders
set theSender to "Sender<user@mac.com>"
set recipCommon to "Sender"
set msgText to ""
set theSubject2 to theSubject & ", " & theCountdown & " of " & item_count as string
-- start Mail
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject2, content:msgText & return & return}
tell newMessage
set visible to true
set sender to theSender
make new to recipient with properties {name:recipCommon, address:recipAddress}
make new attachment with properties {file name:eachitem} at after the last paragraph
end tell
save newMessage
close newMessage
end tell
-- subtract the sent mail from the total count
set theCountdown to theCountdown - 1
end repeat
display dialog item_count & " files for " & recipAddress & " got saved in drafts." buttons {"OK"} default button "OK"
else
-- send
repeat with eachitem in theFolders
set theSender to "Sender<User@mac.com>"
set recipCommon to "Sender"
set msgText to ""
set theSubject2 to theSubject & ", " & theCountdown & " of " & item_count as string
-- start Mail
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject2, content:msgText & return & return}
tell newMessage
set visible to true
set sender to theSender
make new to recipient with properties {name:recipCommon, address:recipAddress}
make new attachment with properties {file name:eachitem} at after the last paragraph
end tell
save newMessage
send newMessage
end tell
-- subtract the sent mail from the total count
set theCountdown to theCountdown - 1
end repeat
display dialog item_count & " files got sent to " & recipAddress buttons {"OK"} default button "OK"
end if
end open
Model: MacBook
AppleScript: 1.10.7
Browser: Safari 525.22
Operating System: Mac OS X (10.4)