Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Reference

macrumors newbie
Original poster
Jan 2, 2007
2
0
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.
 

Reference

macrumors newbie
Original poster
Jan 2, 2007
2
0
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

macrumors G4
Nov 3, 2005
10,434
12,250
UK
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.
 

MongoTheGeek

macrumors 68040
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

Code:
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 {""}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.