PDA

View Full Version : please help me in applescript




Reference
Jan 2, 2007, 06:26 AM
hi out there!

iīm new here und a real big dummy in puncto programming. now i have a special interest: finder-based i would read out the filenames of an defined folder (in my case only files with the ending .pdf", copy them and insert the file names in my standard mail program "mail".

hmm sounds so easy, but isnīt it for me ;)
for help of you specialists out there in the world i would be very happy. thank you so much.



Cromulent
Jan 2, 2007, 07:40 AM
What code have you got down so far? It is hard to help without seeing how far you have got :).

Reference
Jan 2, 2007, 09:34 AM
my code looks like this:

tell application "Finder"
try
mount volume "afp://xxxxx/xxxx" as user name "xxxxx" with password "xxxxxxx"
end try
set theFolder to alias "xxxxxx:xxxxxxx:"
activate
set fileList to (get every file of theFolder whose name ends with "pdf")
repeat with i from 1 to (count fileList)
set str to (name of item i of fileList)
display dialog str
end repeat
end tell

tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"xxxxxxxxxx"}
tell newMessage
set visible to true
set sender to "Absender <xxxxx@xxxxxx>"
make new to recipient at end of to recipients with properties {address:"xxxxxxx@xxxxxxxxx,xxxxxxxxxx@xxxxxxxxx"}
--send
end tell
end tell


the part setfilelist is just a try for me. how do i get the names of my target files in the body of the new mail? thanks

Eraserhead
Jan 2, 2007, 11:02 AM
You can add attachments to an email with Automator, whether it can also be done in Applescript I don't know but it's likely. though you can also add applescript to an automator widget, maybe that's an easier way to go about it. There is more info on this here (http://homepage.mac.com/kmug1/Presentations/AutoScriptDemo/Automator&Applescript-Mailer.html).

MongoTheGeek
Jan 2, 2007, 11:03 AM
my code looks like this:

tell application "Finder"
try
mount volume "afp://xxxxx/xxxx" as user name "xxxxx" with password "xxxxxxx"
end try
set theFolder to alias "xxxxxx:xxxxxxx:"
activate
set fileList to (get every file of theFolder whose name ends with "pdf")
repeat with i from 1 to (count fileList)
set str to (name of item i of fileList)
display dialog str
end repeat
end tell

tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"xxxxxxxxxx"}
tell newMessage
set visible to true
set sender to "Absender <xxxxx@xxxxxx>"
make new to recipient at end of to recipients with properties {address:"xxxxxxx@xxxxxxxxx,xxxxxxxxxx@xxxxxxxxx"}
--send
end tell
end tell


the part setfilelist is just a try for me. how do i get the names of my target files in the body of the new mail? thanks

Set content to filelist

One other thing to do is up at the top


tell application "Finder" to set fileList to (name of every file of theFolder whose name ends with "pdf")
set applescript's text item delimiters to ", "
set fileList to ""&fileList
set applescript's text item delimiters to {""}