Sending messages with AppleScript

173 Views Asked by At

I can send messages to a specified person already using the buddy thing. I have multiple emails registered with iMessage so I was wondering how I can select which account the message is sent from in the actual script?

I have not tried anything because I'm not very familiar with AppleScript

For example:

I would want to send "Hi" from coolemail1 and "How are you" from coolemail2

How could I do this?

-I'm really bad at making questions sorry

1

There are 1 best solutions below

0
On

The sender account is the sender property of the message.

This sender is usually in the form contact_name .

To extract only email address and to compare with your acc1/acc2, you must use "extract address from" instruction.

See example bellow :

set Acc1 to "[email protected]"
set acc2 to "[email protected]"
tell application "Mail"
set theMails to every message of inbox whose subject contains "your selection"
repeat with I from 1 to count of theMails
set My_Sender to extract address from sender of item I of theMails
if My_Sender is Acc1 then
   -- do something
   else
   -- do something else for the second name
   end if
end repeat
end tell