Hi there,
–I have the below script which works well when used via a file dropped on it.
on open DroppedFile
tell application “Finder”
set myMsg to “email address”
set NameOfFile to (name of (info for DroppedFile))
set myFile to DroppedFile as alias
–display dialog NameOfFile
end tell
display dialog NameOfFile & return & return & "Amend or a v1 Build?" buttons {"Amend", "v1 Build", "Cancel"} default button 2
set x to button returned of result
if x is "Amend" then
tell application "Microsoft Outlook"
set mySubject to (NameOfFile & " AMEND FOR APPROVAL" as text)
set myContent to "<p style=font-family:Calibri>...</p><p style=font-family:Calibri>Attached is a low res PDF for approval for the amendment to job " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to DroppedFile
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient at myMsg with properties {email address:{name:"Dave Leicester", address:"test@email.co.uk"}}
end tell
open myMsg
tell application "Microsoft Outlook" to activate
end tell
else if x = "v1 Build" then
tell application "Microsoft Outlook"
set mySubject to (NameOfFile & " v1 BUILD FOR APPROVAL" as text)
set myContent to "<p style=font-family:Calibri>...</p><p style=font-family:Calibri>Attached is a low res PDF for Version 1 Build approval on the job " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to DroppedFile
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient at myMsg with properties {email address:{name:"Dave Leicester", address:"test@email.co.uk"}}
end tell
open myMsg
tell application "Microsoft Outlook" to activate
end tell
else if x = "Cancel" then
display dialog "You Picked Cancelled" default button 1
end if
end open
–However, I now want this to work via a Folder Action, i.e., when a file is dropped into a folder it is assigned to it invokes the script.
It’s not working at all. I’ve searched around and altered the script to the below, but this still does not work. Any ideas what I’m doing wrong?
on adding folder items to thisFolder after receiving DroppedFile
tell application “Finder”
set myMsg to “email address”
set NameOfFile to (name of (info for DroppedFile))
set myFile to DroppedFile as alias
–display dialog NameOfFile
end tell
display dialog NameOfFile & return & return & "Amend or a v1 Build?" buttons {"Amend", "v1 Build", "Cancel"} default button 2
set x to button returned of result
if x is "Amend" then
tell application "Microsoft Outlook"
set mySubject to (NameOfFile & " AMEND FOR APPROVAL" as text)
set myContent to "<p style=font-family:Calibri>...</p><p style=font-family:Calibri>Attached is a low res PDF for approval for the amendment to job " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to DroppedFile
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient at myMsg with properties {email address:{name:"Dave Leicester", address:"test@email.co.uk"}}
end tell
open myMsg
tell application "Microsoft Outlook" to activate
end tell
else if x = "v1 Build" then
tell application "Microsoft Outlook"
set mySubject to (NameOfFile & " v1 BUILD FOR APPROVAL" as text)
set myContent to "<p style=font-family:Calibri>...</p><p style=font-family:Calibri>Attached is a low res PDF for Version 1 Build approval on the job " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to DroppedFile
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient at myMsg with properties {email address:{name:"Dave Leicester", address:"test@email.co.uk"}}
end tell
open myMsg
tell application "Microsoft Outlook" to activate
end tell
else if x = "Cancel" then
display dialog "You Picked Cancelled" default button 1
end if
end adding folder items to
–I’ve added the Folder to the Folder Actions Workflow and assigned the script to it - but when i place a file in there I get nothing.
Please help -it’s driving me mental!!
Regards
Dave