Hello,
I was wondering if there is anyway to create a script that when an item was placed into a folder, that my email application (entourage) would open, then create a new email for a select group of predetermined contacts, and then put the name of the file in the subject and in the body, a generic message that says, " “the Filename” has been added to the current folder"
Something like that.
Is that at all possible???
thanks!
barbara
Hi,
I have no idea to add multiple recipients in a new outgoing message of Entourage,
but here is the rest of your request, just a simple folder action
on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set fileName to name of (info for i)
tell application "Microsoft Entourage"
tell (make new outgoing message with properties ¬
{to recipients:"John@Doe.com", subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
send
end tell
end tell
end repeat
end adding folder items to
The “to recipients” can be a list so multiple would look like this:
tell application “Microsoft Entourage”
tell (make new outgoing message with properties ¬
{to recipients:{“John@Doe.com”, “Jane@Doe.com”, “Jack@Doe.com”}, subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
send
end tell
hey Stefen,
works great… I took your script and added multiple names …see below:
awesome…
on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set fileName to name of (info for i)
tell application “Microsoft Entourage”
tell (make new outgoing message with properties ¬
{to recipients:"Barbara.jones@mac.com, dave.smith@earthlink.net", subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
send
end tell
end tell
end repeat
end adding folder items to
I am going to play with multiple files on our server now and see how it goes.
thanks so much…will keep you posted as I build on it now
barbara
Hi Matt,
I tried your way as well, but it is getting stuck on the word message.
I am getting a syntax error … Expected “,” but found identifier.
I can use my way for now but that looked nicer, so I will try to figure out why that is happening.
thanks!
barb
ok guys…this might be pushing it…but…
can I actually have a link made in the body that picks up the actual location on the server.
So, when the user gets the email they can just click on it to take them to the pdf file on the server?
can’t hurt to ask
Just seems like the final logical step
thanks
barbara
Hi
What if I want to filter out certain filenames.
The script should only be triggered by filnames starting with “jobs”
Application Mail must send the mail
–Peter–
the location of file or folder added to a hot folder is the hot folder itself,
not where the item comes from. If you want to point to the files in this folder
I have added the file URL of the file to the mail, but as I don’t know the structure of your server, it might not work
on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set fileName to name of (info for i)
tell application "Finder" to set theURL to URL of i
tell application "Microsoft Entourage"
tell (make new outgoing message with properties ¬
{to recipients:"Barbara.jones@mac.com, dave.smith@earthlink.net", subject:fileName, content:fileName & " has been added to folder " & (this_folder as text) & return & return & theURL})
send
end tell
end tell
end repeat
end adding folder items to
on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set fileName to name of (info for i)
if fileName starts with "jobs" then
tell application "Mail"
tell (make new outgoing message with properties {visible:true, subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
make new to recipient at end of to recipients with properties {name:"John Doe", address:"john@doe.com"}
send
end tell
end tell
end if
end repeat
end adding folder items to
Thanks Stefan,
Is it possible to have multiple recipients from a group in my adressbook add a signature and mark it as urgent?
property theSignature : "mySignature" -- name of the Mail signature
property theGroup: "myGroup" -- name of the Address Book group
on adding folder items to this_folder after receiving these_items
tell application "Address Book" to set theRecipients to value of emails of people of group theGroup
repeat with i in these_items
set fileName to name of (info for i)
if fileName starts with "jobs" then
tell application "Mail"
tell (make new outgoing message with properties {visible:true, subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
repeat with oneRecipient in theRecipients
make new to recipient at end of to recipients with properties {address:item 1 of oneRecipient}
end repeat
set message signature to signature theSignature
send
end tell
end tell
end if
end repeat
end adding folder items to
The script takes always the first email address of the person in Address Book, if there are more than one.
As far as I know there is no command to set the priority of an outgoing message, maybe it is possible with GUI scripting
Hi Stefan,
There’s something wrong with the signature part
It only works if I leave this out.
I even renamed my default signature to mySignature - doesn’t help
–Peter–
this should work
property theSignature : "mySignature" -- name of the Mail signature
property theGroup : "myGroup" -- name of the Address Book group
on adding folder items to this_folder after receiving these_items
tell application "Address Book" to set theRecipients to value of emails of people of group theGroup
tell application "Mail" to set messageSignature to signature theSignature
repeat with i in these_items
set fileName to name of (info for i)
if fileName starts with "jobs" then
tell application "Mail"
tell (make new outgoing message with properties {visible:true, subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
repeat with oneRecipient in theRecipients
make new to recipient at end of to recipients with properties {address:item 1 of oneRecipient}
end repeat
set message signature to messageSignature
send
end tell
end tell
end if
end repeat
end adding folder items to
Stefan,
It doesn’t solve the problem.
–Peter–
I tested the script above. On my machine it works
Thanks Stefan.
I tested it again AND IT WORKS!!
Hi Stefan,
One more thing:
What if I want to trigger the script with ONLY .zip files and filename starts with… (the last one already build in)
Thanks in advance.
–Peter–
.
repeat with i in these_items
set {name:fileName, name extension:fileExtension} to (info for i)
if fileName starts with "jobs" and fileExtension is "zip" then
tell application "Mail"
.
Hi Stefen,
I am so sorry for the late reply…been one of those weeks…
your script below worked perfect…so cool this stuff
on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set fileName to name of (info for i)
tell application “Microsoft Entourage”
tell (make new outgoing message with properties ¬
{to recipients:"John@Doe.com", subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
send
end tell
end tell
end repeat
end adding folder items to
thanks so much!!!
barbara
hi,
OK…maybe spoke a moment too soon.
I came in this morning and the pdfs I left in the folder last night with the script attached send them again as soon as I took my computer out of sleep mode.
So, then I removed them from the folder and it sent another message saying where they were moved too…
So, how do you stop something that was sent to not send again, and if I remove it from the folder that it does not run the action again.
How might I go about handling that?
thanks!!!
barbara
Specify an archive folder path in the property (with colon at the end!).
The script moves every file to this folder after sending the message.
To avoid overwriting of files with the same file name a timestamp with format YYMMDD-hhmmss_[filename.ext] will be added to the name
property archiveFolder : "MacHD:path:toArchiveFolder:" -- the colon at the end is important!
on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set fileName to name of (info for i)
tell application "Microsoft Entourage"
tell (make new outgoing message with properties ¬
{to recipients:"John@Doe.com", subject:fileName, content:fileName & " has been added to folder " & this_folder as text})
send
end tell
end tell
set newFileName to do shell script "/bin/date +%y%m%d-%H%M%S_" & fileName -- adds a timestamp to the filename
do shell script "/bin/mv " & quoted form of POSIX path of i & space & quoted form of (POSIX path of archiveFolder & newFileName)
end repeat
end adding folder items to
PS: Can you please use the applescript tags for the code you’re going to post