Hey everyone, I’ve been going through forums and reference for a bit and haven’t been able to find something that already exists. Here’s the basic concept:
Send button clicked
AppleScript gets triggered
Message scanned for “attach”,“file”,etc.
If one or more of the words are found, continue – else, send message
Prompt user: “Did you remember your attachment?”
If yes, send – if no, cancel sending
The other option would be a trigger that runs the script and sends if criteria is true:
Shortcut / menu / hotkey triggers AppleScript
Message scanned for “attach”,“file”,etc.
If one or more of the words are found, continue – else, send message
tell application "Microsoft Entourage"
if class of the front window is draft window then
set theWindow to the front window
save theWindow
set theMsg to displayed message of theWindow
close theWindow
else
beep
display dialog "This script only works with a new or draft message open in its own window." buttons {"OK"} default button 1 with icon 0
return
end if
set thePara to the paragraphs of theMsg
set remindAttach to false
repeat with msgLine in thePara
set msgLine to msgLine as text
if msgLine contains "attach" then
set remindAttach to true
end if
end repeat
if remindAttach is true then
display dialog "It appears you wanted to send an attachment. Have you already attached it?" with icon caution buttons ["Yes", "Cancel"] default button 2
if button returned of result is "Yes" then
send theMsg
end if
end if
end tell
So it appears I like talking to myself, but I’ve finally completed the script. It took about 2 hours which is not bad for my second AppleScript ever. If you’re going to use the script below, I’d appreciate my reference comments be intact.
-- Created by Ahmed Sagarwala (am [at] artform .dot. ca)
-- Oct 23, 2008 -=- Version 1.0 stable
-- http://www.artform.ca/
-- ======================
-- Thanks to Paul Berkowitz for posting their AppleScripts online!
tell application "Microsoft Entourage"
-- Get your focus on
activate
-- Make sure we're working with a message window
if class of the front window is draft window then
-- Setup variables
set theWindow to the front window
set theText to the content of theWindow
set thePara to the paragraphs of theText
-- Default to false until proven guilty!
set remindAttach to false
-- Loop through each line and check for the string "attach"
repeat with msgLine in thePara
set msgLine to msgLine as text
set searchVar to offset of "attach" in msgLine
-- See if the attach was found
if searchVar is greater than 0 then
set remindAttach to true
end if
end repeat
-- An attachment is needed
if remindAttach is true then
beep
display dialog "It appears you wanted to send an attachment. Have you already attached it?" with icon caution buttons {"Yes", "No"} default button 2
-- User wants to send the message
if button returned of result is "Yes" then
send theWindow
else
return -- Cancel everything and allow for attachment
end if
else
send theWindow -- No attachment was needed, sending by default
end if
-- Problem: we weren't working with a message window
else
beep
display dialog "This script only works with a new or draft message open in its own window." buttons {"OK"} default button 1 with icon 0
return
end if
end tell
Feedback is also appreciated.
Model: MacBook Pro (2.5 GHz | 4GB RAM | Leopard, XP, Ubuntu 8)
AppleScript: 2.0.1
Browser: Firefox 3.0.1
Operating System: Mac OS X (10.5)
More than the functionality of the (self-explanatory) script, it puzzles me how you 'd want to trigger it.
How would you intercept the obvious hit of the “send” button ?
Great script, thank you ! I’ve introduced a couple of amendments:
For multilingual users: added equivalents of “attach” in Italian, Danish and French besides English. Of course, anyone can change the languages at deemed necessary.
Inversed Yes and No buttons as default (those who send 1 mail out of 10 with an attachment are more likely to forget)
“No” button acts as “Cancel”, i.e. can be activated with the Esc key.
-- Created by Ahmed Sagarwala (am [at] artform .dot. ca)
-- Oct 23, 2008 -=- Version 1.0 stable
-- http://www.artform.ca/
-- ======================
-- Thanks to Paul Berkowitz for posting their AppleScripts online!
tell application "Microsoft Entourage"
-- Get your focus on
activate
-- Make sure we're working with a message window
if class of the front window is draft window then
-- Setup variables
set theWindow to the front window
set theText to the content of theWindow
set thePara to the paragraphs of theText
-- Default to false until proven guilty!
set remindAttach to false
if theText contains "attach" then
set remindAttach to true
else if theText contains "allegat" then
set remindAttach to true
else if theText contains "vedhæft" then
set remindAttach to true
else if theText contains "joint" then
set remindAttach to true
end if
-- An attachment is needed
if remindAttach is true then
beep
display dialog "It appears you wanted to send an attachment. Have you already attached it?" with icon caution buttons {"Yes", "No"} default button 1 cancel button 2
-- User wants to send the message
if button returned of result is "Yes" then
send theWindow
else
return -- Cancel everything and allow for attachment
end if
else
send theWindow -- No attachment was needed, sending by default
end if
end if
end tell
Model: MacBook Pro
AppleScript: 2.1.2
Browser: Firefox 6.0.2
Operating System: Mac OS X (10.6)