Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pirx

macrumors newbie
Original poster
Aug 10, 2017
8
0
Shanghai
Greetings,

I have a question regarding AppleScript. I tried, but I am plainly too uninspired to get it right.

Objective: In Mac OS X Mail, when I click on "Compose new message" I want an AppleScript to run that prompts me to select an SMTP server. The basics I got right, the following script works, but how do I tie it to "Compose new message"?

on run
set myResult to display dialog ¬
"Sending e-mail to Xyz?" buttons {"Yes", "No"}
tell application "Mail"
if the button returned of myResult is "Yes" then
set smtp server of account "ABCD" to ¬
smtp server "XYZ"
else
set smtp server of account "ABCD" to ¬
smtp server "DEFG"
end if
end tell
end run

Would be very grateful for some guidance.

Cheers!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.