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

MacGeekJunior

macrumors newbie
Original poster
Mar 13, 2011
6
0
Hi All,
I have hardly any idea on how to make an applescript app. It is a fairly simple app that will allow me to turn read receipts on and off.
This is what I want my application to do:
A Dialog pops up and asks if you want to turn Read Receipts on or off with with two buttons (on and off).
If 'on' is pressed: terminal is opened and then this is typed in:
defaults write com.apple.mail UserHeaders '{"Disposition-Notification-To" = "Name <email@address>"; }'
If 'off' is pressed: terminal is opened and then this is typed in:
defaults delete com.apple.mail UserHeaders
Then terminal is closed.

End of application.

This is all the code I have so far:
tell application "Terminal"
activate
end tell

Thanks guys for the help.
 

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
You don't need to use the Terminal, a shell script can be run directly from the AppleScript, for example:

Code:
property emailAddress : quote & "Name <email@address>" & quote

display alert "-- Set Mail Read Receipts --" message "This script will set a preference for Read Receipts in the Mail application (com.apple.mail UserHeaders)." buttons {"Cancel", "On", "Off"} cancel button "Cancel" default button "Cancel"

if button returned of the result is "On" then
	do shell script "defaults write com.apple.mail UserHeaders '{\"Disposition-Notification-To\" = " & emailAddress & "; }'"
else
	do shell script "defaults delete com.apple.mail UserHeaders"
end if
 

MacGeekJunior

macrumors newbie
Original poster
Mar 13, 2011
6
0
Thanks

You don't need to use the Terminal, a shell script can be run directly from the AppleScript, for example:

Code:
property emailAddress : quote & "Name <email@address>" & quote

display alert "-- Set Mail Read Receipts --" message "This script will set a preference for Read Receipts in the Mail application (com.apple.mail UserHeaders)." buttons {"Cancel", "On", "Off"} cancel button "Cancel" default button "Cancel"

if button returned of the result is "On" then
	do shell script "defaults write com.apple.mail UserHeaders '{\"Disposition-Notification-To\" = " & emailAddress & "; }'"
else
	do shell script "defaults delete com.apple.mail UserHeaders"
end if

Thanks. Works perfectly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.