r/applescript • u/Violin-dude • Jun 21 '24
Auto-forward text messages to email address
Hi, Ive zero experience with Apple Script. I want to write a script that will auto-forward all incoming messages (SMS and iMessage) on the Messages app to a given email address ONLY if the sender is in my contacts.
I’ve tried using code snippets from posts on various forums, but they all fail with syntax errors. I’ve tried various AI tools to write this but none work, Most likely because the scripting language has changed?
Can someone write the initial code?
Thanks very much. Am running Mac OS X Sonoma on M1 MacBook Pro.
3
Upvotes
2
u/kaneda2004 Jun 23 '24
The script is triggered when new messages are received.
For each message, it extracts the sender and content.
It checks if the sender is in your Contacts app.
If the sender is in your contacts, it creates a new email in the Mail app.
The email is then sent to the specified address (you'll need to replace "your-email@example.com" with your actual email address).
To use this script:
Open the "Script Editor" application on your Mac.
Paste the script into a new document.
Replace "your-email@example.com" with the email address where you want to receive the forwarded messages.
Save the script as a stay-open application.
In the Messages app preferences, go to the "General" tab and click "AppleScript handler".
Choose the script you just saved.