Hi all,
So I wrote a backup script which, at the end, fires up Mail.app and has it send the backup log to various people. This was working fine until about 2 weeks ago, when it suddenly broke. Now it no longer sends the email, although if I go to the backup server and manually launch Mail.App, the email will get sent out (I guess it’s getting constructed property and getting queued but not getting sent).
Here’s what I’ve got (NOTE: I’ve changed the sending and receiving email addresses here for anonymity purposes):
if BackupSuccess is equal to true then
set theSubject to "Backup succeeded on " & m & " " & d & " " & y
set theBody to "The backup on " & m & " " & d & ", " & y & " succeeded and backed up roughly " & legibleSize & " GB of data."
else
set theSubject to "Backup failed (at least partially) on " & m & " " & d & " " & y & "!"
set theBody to "The backup run on " & m & " " & d & ", " & y & " failed. Attached is the backup log."
set theAttachment to POSIX path of log_target
end if
set theSender to "user1@domain.com"
set theName to "File Server"
set theAddress to "user2@domain.com"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
tell newMessage
set visible to true
set sender to theSender
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
if BackupSuccess is equal to false then
tell content
make new attachment with properties {file name:theAttachment} at after the last paragraph
end tell
end if
end tell
send newMessage
delay 15
quit
end tell
Anyone have any ideas to why this isn’t working? I realize the problem might be with mail.app itself (perhaps one of the OS X updates broke it) but I think the likelier culprit is the “send” Applescript command.
Thanks much!
Cheers,
John