Here is a script I have to watch the Fax-folders content and send the files as attachment by mail.
Somehow I cannot get it work, as it stops in line >set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent & return & return, recipient:theRecipient}
Any suggestions or corrections are welcome! Thanks!
tell application “Finder”
set theHome to (path to home folder) as reference
set theFolder to item “Fax” of theHome
set theCount to count of items in theFolder
end tell
if theCount > 0 then
repeat with theLoop from 1 to theCount
set theFile to the item theLoop of theFolder
set theString to the (item theLoop of theFolder) as string
set theBody to the POSIX path of theString
send_mail(theBody)
delete theFile
end repeat
end if
on send_mail(theBody)
tell application “Mail”
set theAddress to “faxes@welkam.co.jp”
set theName to “FAX”
set theRecipient to theAddress
set theSubject to “New Fax received!”
set theContent to (theBody as string)
set theAttachment to theContent
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent & return & return, recipient:theRecipient}
tell theMessage
set visible to false
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
end tell
send theMessage
end tell
end send_mail
Model: Mac Pro
AppleScript: 2.0.1
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)