Applescript send mail with default application

You can use the following AppleScript to send an email using the default email application:

tell application "Mail"
    set theMessage to make new outgoing message with properties {subject:"Test Email", content:"Hello, this is a test email."}
    tell theMessage
        make new to recipient at the end of recipients with properties {name:"Recipient's Name", address:"[email protected]"}
    end tell
    send theMessage
end tell

This script creates a new outgoing message, sets the subject and content, adds a recipient, and then sends the message.

If you want to use the default email application, you can use the following script:

tell application "System Events"
    set defaultEmailApp to (application processes whose name contains "Mail")
    tell application defaultEmailApp
        set theMessage to make new outgoing message with properties {subject:"Test Email", content:"Hello, this is a test email."}
        tell theMessage
            make new to recipient at the end of recipients with properties {name:"Recipient's Name", address:"[email protected]"}
        end tell
        send theMessage
    end tell
end tell

This script uses System Events to get a list of running applications, and then finds the one that contains the word "Mail" (which is likely to be the default email application). It then uses that application to create and send the email.

Note that this script assumes that the default email application is Mail. If you want to use a different email application, you'll need to modify the script accordingly.

Also, you can use tell application "Microsoft Outlook" or tell application "Entourage" if you want to use Outlook or Entourage as the default email application.

You can also use tell application "Automator" to send email using Automator's built-in email action.

You can also use do shell script command to send email using command line email client like mutt or msmtp

For example:

do shell script "mutt -s 'Test Email' [email protected] <<EOF
Hello, this is a test email.
EOF"

This will send an email using the mutt command line email client.

Please note that you need to have the email client installed and configured on your system for this to work.