PDA

View Full Version : applescript help (rename files in folder)& add file as attachment in entourage outbox




s2mcpaul
Feb 12, 2008, 09:58 PM
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.



s2mcpaul
Feb 13, 2008, 05:09 PM
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


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

s2mcpaul
Feb 14, 2008, 01:23 PM
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!:


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