1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

please help me in applescript

Discussion in 'Mac Programming' started by Reference, Jan 2, 2007.

  1. macrumors newbie

    #1
    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.
     
  2. macrumors 603

    Cromulent

    #2
    What code have you got down so far? It is hard to help without seeing how far you have got :).
     
  3. macrumors newbie

    #3
    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
     
  4. macrumors G4

    Eraserhead

    #4
    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.
     
  5. macrumors 68040

    MongoTheGeek

    #5
    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 {""}
    
     

Share This Page