Applescript - email file as attachment problem

Hi,
I'm trying to grab files with a certain extension from a folder once Carbon Copy Cloner has copied them from a drive and ten email them one at a time as attachments.
My rules for this section are:
Date added is today
Extension is XXX
For testing purposes I then get Hazel to email me that it worked and has completed.
The confirmation email worked however the email with file attachment failed.
Here's the relevant log section:
I had no interaction with it so I'm not sure why it keeps saying 'User canceled'
Here's the applescript I used;
Mr Seagull
I'm trying to grab files with a certain extension from a folder once Carbon Copy Cloner has copied them from a drive and ten email them one at a time as attachments.
My rules for this section are:
Date added is today
Extension is XXX
For testing purposes I then get Hazel to email me that it worked and has completed.
The confirmation email worked however the email with file attachment failed.
Here's the relevant log section:
2016-06-07 20:02:56.142 hazelworker[959] [Error] AppleScript failed: Error executing AppleScript on file /Users/MacMini/Dropbox/Apps/Bryton/160603053919.fit.
2016-06-07 20:02:56.251 hazelworker[959] OSAScript error: {
NSLocalizedDescription = "Mail got an error: User canceled.";
NSLocalizedFailureReason = "User canceled.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,40040 \"Mail\"]>";
OSAScriptErrorAppNameKey = Mail;
OSAScriptErrorBriefMessageKey = "User canceled.";
OSAScriptErrorMessageKey = "Mail got an error: User canceled.";
OSAScriptErrorNumberKey = "-128";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
I had no interaction with it so I'm not sure why it keeps saying 'User canceled'
Here's the applescript I used;
- Code: Select all
set theAttachment1 to (POSIX path of theFile)
set subject_ to "SUBJECT"
set the_content to "CONTENT"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:subject_, content:the_content & return & return}
tell newMessage
set visible to false
set sender to "xxxxxxxxx@xxxxxx.com"
make new to recipient at end of to recipients with properties {address:"XXXXXXX@XXXXX.XXX"}
make new attachment with properties {file name:theAttachment1} at after the last paragraph
(* change save to send to send*)
send --<<<<---------------- change save to send to send or send to save to save to drafts
(* change save to send to send*)
end tell
end tell
Mr Seagull