PDA

View Full Version : AppleScript to TEXT me when certain emails come in




John Greer
Jan 30, 2012, 01:05 PM
Currently, I have a Mail Rule that forwards certain emails to me, via SMS text.
It comes over unformatted for text, very ugly and hard to read.
I would like an AppleScript to send me a text that only has FROM and SUBJECT. Once I see that, I can get the rest form my iPhone. I just don't want to miss these emails.

All I really need is a script that can "read" the FROM, SUBJECT, SENT_TIME and SENT_DATE. From that, I can then create a new email (assuming I figure out how) and send that to my phone.

Has anyone already written this script?



John Greer
Feb 3, 2012, 04:38 PM
So I got this to work in the AppleScript Editor:
tell application "Mail"
set newMsg to make new outgoing message
set content of newMsg to "Test Message from Mail2text.scpt"
set sender of newMsg to "someone"
set subject of newMsg to "Test"
tell newMsg
make new to recipient at end of to recipients with properties {address:"mynumber@txt.att.net"}
send
end tell
--set visible of newMsg to true
--display dialog theContent
--say theContent
end tell

but I cannot get it to work via a rule:
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theSelectedMessages
tell eachMessage
set f to sender of eachMessage
set s to subject of eachMessage
set ds to date sent of eachMessage
set dr to date received of eachMessage
--say theContent
--display dialog theContent
set newMsg to make new outgoing message
set sender of newMsg to f
set subject of newMsg to s
set content of newMsg to "Message from" & sender & " sent:" & date sent & ", received:" & date received
tell newMsg
make new to recipient at end of to recipients with properties {address:"mynumber@txt.att.net"}
send
end tell
--set visible of newMsg to true
--display dialog theContent
--say theContent
end tell
end repeat
end tell
end perform mail action with messages
end using terms from

sero
Feb 4, 2012, 09:29 AM
Wirelessly posted (Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3)

I've done this before with gmail (pretty simple). I think it makes more sense to set this up at the mail server end, rather than in your mac. What if you Mac is off or not connected, etc?