0

I have a script to send an email, but I'd like to detect if no email account is setup, and to do something else.

Is there a way to detect or trap for this condition? Thanks.

tell application "Mail"
    set new_message to make new outgoing message with properties {visible:false, subject:"AppleScript-2014", content:("Success " & linefeed & "user: " & userName & linefeed & "OS: " & (system version of (get system info)) as rich text) & linefeed & "IP: " & IPv4 address of (get system info)}

    tell new_message
        make new to recipient with properties {name:"Len", address:"me@law.edu"}
    end tell
    delay 7
    send new_message
end tell
0

This ought to do it...

tell application "Mail"
    set nAccounts to every account
    log "Number of accounts: " & (get count of nAccounts)
end tell
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .