Chris deftly typed--

>
>>So, the Catch 22 is how to catch blank email with spam html (deleting 
>>automatically the enclosures) and the blank email with no attachment 
>>without getting Emailer to hang.
>
>Without seeing the script that trashes the message, I can't give you a 
>complete answer... but if it was me, I would either check to see if an 
>attachment exists before trashing it, or enclose the trash step in a 
>"try" block.
>
>-chris
><http://www.mythtech.net>

Chris:

Herein the script:
---------------------------------------------------------------------------
--
(* GetSelectedMessages v2
** by David Cortright <[EMAIL PROTECTED]>
** classFilter: the class of message this script processes
**                   "incoming message", "outgoing message", or "message"
** fProcessOpenMessages: a flag indicating whether or not to process an 
open message
**                                      true or false
** returns a list of messages of the specified class or {} if there are 
no messages of the specified class
*)
on GetSelectedMessages(classFilter, fProcessAnOpenMessage)
        tell application "Claris Emailer"
                if classFilter is "incoming message" then
                        set messageClass to incoming message
                else if classFilter is "outgoing message" then
                        set messageClass to outgoing message
                else
                        set messageClass to message
                        set classFilter to "message"
                end if
                
                try
                        set messagesOfUnknownClass to {the filtered message}
                        
                on error
                        if the class of the front window is browser window then
                                set messagesOfUnknownClass to the selection of the 
front window
                                
                        else if the class of the front window is incoming message 
window or �
                                the class of the front window is outgoing message 
window then
                                if fProcessAnOpenMessage is true then
                                        try
                                                set messagesOfUnknownClass to {the 
displayed message of the front 
window}
                                        on error
                                                try
                                                        set the subject of the 
displayed message of the front window to �
                                                                (get the subject of 
the displayed message of the front window)
                                                        select menu item "Save" of 
menu "File"
                                                        set messagesOfUnknownClass to 
{the displayed message of the front 
window}
                                                end try
                                        end try
                                else
                                        set messagesOfUnknownClass to {}
                                end if
                        end if
                end try
                
                if messageClass is message then
                        set selectedMessages to messagesOfUnknownClass
                        
                else
                        set selectedMessages to {}
                        repeat with theMessage in messagesOfUnknownClass
                                if the class of theMessage is messageClass then
                                        set selectedMessages to selectedMessages & 
theMessage
                                end if
                        end repeat
                end if
        end tell
        
        if selectedMessages is {} then
                if fProcessAnOpenMessage is true then
                        set singleMessageAddendum to "or have one open in its own 
window "
                else
                        set singleMessageAddendum to ""
                end if
                tell me to display dialog "You need to select at least one " & 
classFilter & " in the Browser " & �
                        singleMessageAddendum & "in order to use this script." buttons 
{"OK"} 
default button "OK" with icon note
        end if
        
        return selectedMessages
end GetSelectedMessages


set selectedMessages to GetSelectedMessages("message", true)
if selectedMessages is {} then return

set fNoValidEnclosures to false
repeat with theMessage in selectedMessages
        try
                tell application "Claris Emailer"
                        set theEnclosures to (name of every file of theMessage)
                end tell
                
                tell application "Finder"
                        repeat with theFilename in theEnclosures
                                set theFileToDelete to (the item named theFilename)
                                delete theFileToDelete
                        end repeat
                end tell
                
        on error
                set fNoValidEnclosures to true
        end try
end repeat

if fNoValidEnclosures is true then
        display dialog "At least one of the selected messages has no valid 
enclosures." & �
                "" buttons {"OK"} default button "OK" with icon caution
end if
---------------------------------------------------------------------------
----

As to your suggestion about examining each message first before deleting, 
I'd rather figure out away for Emailer to do this as 99% of messages with 
attachments (html attachments anyway) are spam.

Again the goal is to have emailer examine messages with no space and if 
that message with no space has an attachment, run the "strip enclosures" 
script. Messages with no space and no attachements should not trigger the 
script, which will hang if no attachment is found.

BTW, all mail with no spaces is automatically put in the deleted mail 
folder by my "html attachment" script.

TIA

Berndt von Wahlde
Academic International Press
PO Box 1111 * Gulf Breeze FL 32562-1111
850 934 0953 (fax) / [EMAIL PROTECTED] (e-mail) / www.ai-press.com
-------------------------------------------------------------------------
"it's a perfect day for making out
to wake up with a smile without a doubt
to burst grin giggle bliss skip jump sing and shout
let's get happy!
it's a perfect day for doing the unstuck"
--the cure

___________________________________________________________________________
To unsubscribe send a mail message with a SUBJECT line of "unsubscribe" to
<[EMAIL PROTECTED]>  or  <[EMAIL PROTECTED]>

Reply via email to