I have a Script that takes downloaded eml files and then opens them ready to send in Outlook. I works in the Script Debugger but in a folder action, it opens every email twice.
It opens quickly on some Mac’s but others are very slow to run the Automator Script.
Lastly, it also leaves a copy in the Drafts folder, for no reason I can see.
Any help would be appreciated.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set ext to "slademl"
set extNew to "eml"
tell application "Finder"
set filesToRename to files of folder "Macintosh HD:Users:julianabbs:Downloads" whose name ends with ext
repeat with aFile in filesToRename
set fileName to name of aFile
set name of aFile to text 1 thru -8 of fileName & extNew
end repeat
end tell
tell application "Finder"
set mlist to (every file of folder "Macintosh HD:Users:julianabbs:downloads" whose name extension is extNew) as alias list
repeat with this_file in mlist
tell application "Microsoft Outlook"
open this_file
set theMessage to item 1 of (get current messages)
set theSource to source of theMessage
set theAccount to default account
set newmessage to make new outgoing message with properties {account:theAccount, source:theSource}
close window 1 saving no
open newmessage
end tell
end repeat
delete (every item of folder ("Macintosh HD:Users:julianabbs:downloads") whose name ends with ".eml")
end tell