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 in this forum, but they all fail. I’ve tried various AI tools to write this but none work, Most likely because the scripting language has changed?

Thanks very much. Am running Mac OS X Sonoma on M1 MacBook Pro.

I think you’re out of luck.

Messages used to support handlers that could intercept and process incoming messages - kind of a prerequisite for what you’re asking here. However, it appears to be deprecated and removed from recent versions.

To do it without explicit support would require periodic polling of the app to see if new messages have come in (along with some record of state so you know what’s new from the last time you checked). Possible, but not something a self-confessed novice would likely be able to craft.

OK, I’m going to have to take this on as a challenge. Am a retired computer scientist, so not much of an issue except fit having to learn a language for a one-off thing.

I’ll do it in JavaScript. As an alternative to AppleScript, I can use it right?

I think you’re misunderstanding the problem.

It’s not an AppleScript vs. JavaScript question, it’s the fact that doesn’t expose the information you’re looking for - there’s no easy way to intercept an incoming message, which is kind of a pre-requisite.

1 Like