Hi
I'm new to Hazel and currently in a trial period on the verge of buying this product. I want to use it for automatically sending invoices on iCloud to my accounting software by sending new files on a folder to an email recipient so that it uploads to the accounting package.
I created this action but it ends up in sending the email correctly with the sender/recipient/subject and content but the file itself that is the trigger of the action is not uploaded/attached.
Can someone help me out on this?
Kind regards
Wout
Script:
-- Convert Hazel's provided file path to a file reference for Mail
set theAttachment1 to (POSIX file theFile)
-- Define the email subject and body
set subject_ to "Nieuw Aankoopfactuur"
set the_content to "Er is een nieuw aankoopfactuur geüpload. Zie bijlage."
-- Create and send the email
tell application "Mail"
-- Create a new outgoing message
set newMessage to make new outgoing message with properties {subject:subject_, content:the_content & return & return, sender:"test@account.com"}
tell newMessage
-- Add recipient
make new to recipient at end of to recipients with properties {address:"recipient@mail.be"}
-- Attach the file
try
make new attachment with properties {file name:theAttachment1} at after the last paragraph
on error errMsg
display dialog "Error attaching file: " & errMsg
end try
-- Set visibility to false for silent sending
set visible to false
-- Send the email
send
end tell
end tell