Script to send a single autoreply
Script to send a single autoreply
- Subject: Script to send a single autoreply
- From: WJ Shack <email@hidden>
- Date: Sat, 19 Jul 2003 18:17:34 -0500
I use a stay open application that tracks replies to avoid Mr. Rips problem.
I also have set it up so that you can build a list of Excluded Names (like
mailing lists) to which replies are never sent. I commented that out in the
script, but I have also added a script which can be used to easily build the
list of excluded names. Note that you have to change the file paths to fit.
property check_minutes : 10 --change this value to new interval
global thereply, excluded_names, used_names
--dialog box to get reply message
activate --always call activate before calling a dialog box
try
set new_message to display dialog "Enter message for autoreply" default
answer "
email autoreply untouched by human hands
I will be away from the Lab until
To avoid bombarding you with robot emails, this will be the only autoreply
you will receive.
"
set thereply to text returned of result
on error
quit
end try
set used_names to ""
(*--opens file containing excluded names
set file_path to "Macintosh HD:Users:shack:Documents:Excluded Names"
set file_ref to open for access file file_path
set fileText to read file_ref as text
close access file file_path
set excluded_names to fileText
--initialize variable containing names of senders
set used_names to excluded_names*)
on idle
try
tell application "Microsoft Entourage"
activate
set themsgs to messages in folder "Inbox"
repeat with theMsg in themsgs
if read status of theMsg is untouched then
set therecipient to sender of theMsg
set firstLast to display name of therecipient
set match to 0 --check to see if sender is on excluded
list
set theSubject to subject of theMsg
if theSubject starts with "*****" then
set match to 1
set the read status of theMsg to read
end if
if match = 0 then --check to see if sender is on list
of recipients of autoreply
set AppleScript's text item delimiters to return
count text items of used_names
set nItems to result
set i to 0
repeat while (i < nItems and match = 0)
set i to i + 1
set testname to text item i of used_names
if firstLast = testname then
set match to 1
set the read status of theMsg to read
--exit main repeat
end if
end repeat
end if
if match = 0 then --check to see if sender is on list
of recipients of autoreply
set AppleScript's text item delimiters to return
count text items of used_names
set nItems to result
set i to 0
repeat while (i < nItems and match = 0)
set i to i + 1
set testname to text item i of used_names
if firstLast = testname then
set match to 1
set the read status of theMsg to read
--exit main repeat
end if
end repeat
end if
if match = 0 then --sender is not on excluded list or on
list of recipients of autoreply
set theSubject to subject of theMsg
set newsubject to "Re: " & theSubject
set replymsg to make new outgoing message with
properties {subject:newsubject, content:thereply, recipient:{recipient
type:to recipient, address:therecipient}}
send replymsg
set the read status of theMsg to read
end if
if match = 0 then
set stuff to (firstLast & return)
set used_names to (used_names & stuff)
end if
end if
end repeat
end tell
on error
--onward
end try
return (check_minutes * 60)
end idle
--set up auto reply
tell application "Microsoft Entourage"
activate
try
set currentMessages to the current messages
set theMsg to item 1 of currentMessages
on error -- no displayed message because more than one message selected
in message pane
display dialog "You must select just one received message in the
message pane to view in the Preview pane, or open it into its own window in
the front." buttons {"OK"} default button "OK" with icon stop
return
end try
set theFrom to the sender of theMsg
set displayToName to the display name of the theFrom
end tell
display dialog "Enter the name of the sender to whom replies should not be
sent. The name must exactly match that given in the \"From\" field in the
mail message." default answer displayToName
set xName to text returned of result
set file_path to "Macintosh HD:Users:shack:Documents:Excluded Names"
set file_ref to open for access file file_path with write permission
set eof_position to (get eof file_ref)
write (return & xName) to file_ref starting at eof_position
close access file_ref
set file_path to "Macintosh HD:Users:shack:Documents:Excluded Names copy"
set file_ref to open for access file file_path with write permission
set eof_position to (get eof file_ref)
write (return & xName) to file_ref starting at eof_position
close access file_ref
tell application "Microsoft Entourage"
activate
end tell
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.