applescript help (rename files in folder)& add file as attachment in entourage outbox

Discussion in 'Mac Programming' started by s2mcpaul, Feb 12, 2008.

  1. macrumors member

    Joined:
    May 14, 2006
    #1
    I'm trying to create an applescript for the following issue:

    What I have done:
    I have a long list 400+ personalized letters that I need to send out to a 'few' people. I did a mail merge in word to print to a virtual printer which then saved each 'form' as a separate pdf file.

    Problem 1:
    The problem is I would like to rename each file from a list that I would create in excel.

    Problem 2:
    I then want to attach the pdf file to individual e-mails that have been created and are waiting in my "Entourage" outbox.

    I would certainly be indebted to anyone who can help me out on this one.
     
  2. thread starter macrumors member

    Joined:
    May 14, 2006
    #2
    Problem 1 solved:
    With new file name in first column and HFS(!) File path in 2nd column.
    HFS(!) being Macintosh HD:Users:Yourname:Desktop:FolderName:File

    HTML:
    set excelFile to choose file with prompt "Choose the Excel file" of type {"XLS6", "XLS7", "XLS8"}
    tell application "Microsoft Excel"
    	open excelFile
    	set P to value of used range of active sheet
    end tell
    repeat with i in P
    	tell application "Finder" to set name of file (item 2 of i) to item 1 of i
    end repeat
     
  3. thread starter macrumors member

    Joined:
    May 14, 2006
    #3
    Partial solution to Problem 2:

    This does both changes the name and creates an email with the new file attached. The only thing is that I wanted to attach the new file to an already created outbox message that has text in it. But Soo Close!:

    HTML:
    set excelFile to choose file with prompt "Choose the Excel file" of type {"XLS6", "XLS7", "XLS8"}
    tell application "Microsoft Excel"
    	open excelFile
    	set P to value of used range of active sheet
    end tell
    repeat with i in P
    	set theFile to item 2 of i as alias
    	tell application "Finder" to set name of theFile to item 1 of i
    	
    	tell application "Microsoft Entourage"
    		activate
    		try
    			set myMessage to make new outgoing message with properties ¬
    				{to recipients:"you@anywhere.net", subject:"Send File ", attachment:theFile}
    			open myMessage
    		end try
    	end tell
    end repeat
     

Share This Page