i use Entourage 2004
I want to have a rule for ALL my emails so that when receiving:
IF there is ANY email with an attachment containing the name “MILESTONE” then it should save ONLY the attachment containing the name “MILESTONE” to a specific folder. After it is saved, it should then OPEN the attachment in excel and PRINT. After PRINT is finished, it should RUN an additional applescript (which I have already got help writing).
any ideas? I have no idea where to begin because i really dont know how to do any of this. Everyone else basically wrote my other code for me. Luckily we have some nice people here. And I am learning by reading the correct code btw, so thank you for teaching me too.
folder action scripting is the way to go here
just make your rule to download to a watced folder then your folder action script can handle what ever you want to do with the download file
ive never done anything with a “watched folder” of folder scripts…so unsure there…
also…but what about all the other unwanted files in the email?
in Library:scripts:folder action scripts there are several apple created folder action scripts you could use as an example
as far as the files you don’t want to print etc. just discard them in the the script something like this
repeat with afile in added_itemes
if name of afile contains "MILESTONES" then
-- your code here
else
delete file afile
end if
end repeat
Time to go install Entourage
James,
are you trying to do the same thing for yourself ?
bluenote,
It seems as though you might want to pick up a book… You shouldn’t rely on others to write your code for you… you could ware out your welcome that way.
mm
Model: MacBookPro (intel)
Browser: Firefox 2.0.0.1
Operating System: Mac OS X (10.4)
Oh me, nah (Apple Mail for life)… Figred to try and figure out the solution though it would help to have the dictionary and the app
The script is a quick edit of one of my scripts, and so is only an example of how to get the attachments whose names contain “MILESTONE”
This only saves the “MILESTONE” files down to your folder.
set homeFolder to path to home folder
set attachFolderPath to "Macintosh HD:Users:UserName:Desktop:test folder:" as string
tell application "Microsoft Entourage"
set theMsgList to {}
set messages_ to the selection
repeat with i from 1 to number of items in messages_
set theMsg to item i of messages_
copy theMsg to end of theMsgList
end repeat
repeat with i from 1 to number of items in theMsgList
set theMsg to item i of theMsgList
set mID to ID of theMsg
set msgAttachments to (every attachment of theMsg whose name contains "MILESTONE")
repeat with i from (count msgAttachments) to 1 by -1
set theAttachment to item i of msgAttachments
set attachName to mID & "_" & name of theAttachment as string
save theAttachment in (attachFolderPath & attachName as string)
end repeat
end repeat
end tell
OK…i’m almost there…
First I made an Entourage Rule to run the following applescript on all incoming mail:
set homeFolder to path to home folder
set attachFolderPath to "TINWOODSMAN:Users:TINWOODSMAN:Desktop:Project Info:Milestones:" as string
tell application "Microsoft Entourage"
set theMsgList to {}
set messages_ to the selection
repeat with i from 1 to number of items in messages_
set theMsg to item i of messages_
copy theMsg to end of theMsgList
end repeat
repeat with i from 1 to number of items in theMsgList
set theMsg to item i of theMsgList
set msgAttachments to (every attachment of theMsg whose name contains "MILESTONE")
repeat with i from (count msgAttachments) to 1 by -1
set theAttachment to item i of msgAttachments
set attachName to name of theAttachment as string
save theAttachment in (attachFolderPath & attachName as string)
end repeat
end repeat
end tell
So far so good, as only the Milestone attachments are saved to the folder.
Next I made a Folder Action on the “Milestones” folder as follows:
on adding folder items to this_folder after receiving added_items
tell application "Microsoft Excel"
open added_items
print out active sheet
close front window
end tell
end adding folder items to
Again, This works great…except there is a slight snag. If there is multiple files, it does not print them all. It will only print the front most active sheet. How do i get it to print each file? In past I was able to do something similar by adding a close front window, repeat print …but this isnt working here…
try iterating through them this may do the trick
on adding folder items to this_folder after receiving added_items
tell application "Microsoft Excel"
repeat with anitem in added_items
open anitem
print out active sheet
close front window
end repeat
end tell
end adding folder items to
mm
ok…so that latest revision got the folder actions to open and print each document correctly…
BUT…i realized now that Entourage does not automatically save the attachments on incoming mail. If i right click on the message and hit “apply rule :: Milestone” it will save the message and so forth…but I want this to happen automatically…
what did i do wrong?
no suggestions on what im doing wrong thats causing the script to not run automatically on all incoming mail?
if someone is interested in finalizing my script for me…plus a few other additions that have already partial working status…i’d be more than happy to donate USD $50 to this site or charity of their choice.
let me know.
I need this to work URGENTLY
all you have to do is apply the rule to all incoming messages
mm
i did…and it doesnt do it…
i thought maybe it has something to do with the applescript in the beginning…not sure.
seriously though…i have a bunch of other stuff i want incorporated…and id like it ASAP…
anyone interested in doing this for me and ill donate some moolahh?
Just wondering if you did set the script to pick up the incoming messages rather than as in the script I posted which has from selection
ok…this is friggin frustrating…
So…I revised the code (see below) to try to get it to only apply to new messages when they are received. Well…it still does not do this automatically…AND now it does not work if I manually select “Apply Rule…”
On top of that…if i re-grab the previous code from my earlier post that worked…even that does not work anymore. I don’t know what’s happening. As this is very urgent…can someone help me just bang this out?
I need it to scan all incoming messages automatically as they are received, and see if its got the “milestone” attachment. If it does…then save it to a specific folder. If it doesn’t, then ignore it.
I already created a new Rule in Entourage so that
IF: Subject contains Milestone
Then: Set category to Milestones AND Run Applescript…
set attachFolderPath to "TINWOODSMAN:Users:TINWOODSMAN:Desktop:Project Info:Milestones:" as string
tell application "Microsoft Entourage"
set theMsgList to {}
set messages_ to the current messages
repeat with i from 1 to number of items in messages_
set theMsg to item i of messages_
copy theMsg to end of theMsgList
end repeat
repeat with i from 1 to number of items in theMsgList
set theMsg to item i of theMsgList
set msgAttachments to (every attachment of theMsg whose name contains "MILESTONE")
repeat with i from (count msgAttachments) to 1 by -1
set theAttachment to item i of msgAttachments
set attachName to name of theAttachment as string
save theAttachment in (attachFolderPath & attachName as string)
end repeat
end repeat
end tell