Created
December 14, 2011 19:19
-
-
Save reinvented/1478037 to your computer and use it in GitHub Desktop.
Applescript to test length of incoming mail's Subject line and reply with a warning for short subject.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on perform_mail_action(info) | |
-- Definition of a Carriage Return. You don't need to change this. | |
set crlf to (ASCII character 13) & (ASCII character 10) & (ASCII character 13) & (ASCII character 10) | |
-- My name is… (set to your own first name; it's used at the end of the email) | |
set myName to "Peter" | |
-- The first part of the automatic reply to be sent... you want to customize this. The sender's subject gets tacked on the end. | |
set theReplyOne to "Hi there," & crlf & "You recently sent me an email message with the very short subject of '" | |
-- The second part of the automatic reply to be sent... you want to customize this. | |
set theReplyTwo to "'." & crlf & "I get a lot of email, and it really, really helps me if the subject contains a brief 10-words-or-less summary of the message. So instead of 'Wednesday' as a subject, I would prefer 'Can we meet Wednesday at 9:00 a.m.?'" & crlf & "I've received and will read your email, so there's no reason to resend it, but I'd appreciate it if you would consider this suggestion for future communications." & crlf & myName & crlf | |
-- How many words are in a subject line that's too short (this value or FEWER words) | |
set theWordCount to 7 | |
tell application "Mail" | |
set selectedMessages to |SelectedMessages| of info | |
repeat with theMessage in selectedMessages | |
set theSubject to subject of theMessage | |
set theSender to sender of theMessage | |
set subjectWords to count words of (theSubject) | |
if (subjectWords < theWordCount) then | |
set theNewMessage to make new outgoing message with properties {subject:"Your email with subject '" & theSubject & "'", content:theReplyOne & theSubject & theReplyTwo, visible:false} | |
tell theNewMessage | |
make new to recipient at end of to recipients with properties {address:theSender} | |
send | |
end tell | |
end if | |
end repeat | |
end tell | |
end perform_mail_action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment