powermail-discuss Digest #2616 - Monday, April 23, 2007

  Applescript not triggering, WAS Attachment link failing
          by "Rick Lecoat" <[EMAIL PROTECTED]>
  Re: Applescript not triggering, WAS Attachment link failing
          by "Tim Hodgson" <[EMAIL PROTECTED]>
  Re: Applescript not triggering, WAS Attachment link failing
          by "Rick Lecoat" <[EMAIL PROTECTED]>
  Re: Applescript not triggering, WAS Attachment link failing
          by "cheshirekat" <[EMAIL PROTECTED]>
  Re(2): Applescript not triggering, WAS Attachment link failing
          by "Winston Weinmann" <[EMAIL PROTECTED]>


----------------------------------------------------------------------

Subject: Applescript not triggering, WAS Attachment link failing
From: "Rick Lecoat" <[EMAIL PROTECTED]>
Date: Mon, 23 Apr 2007 09:56:02 +0100

On a sort-of-related note:

I have an apple script (not written by me -- I have no skills in that
arena) that is supposed to fire any time a message comes in with an
attachment. The script writes to the attached file's Finder comments
(are they still called Finder Comments?), making a note of who sent the
file and the date. This is really useful because, although I also have
had no problem with PM losing the links to attachments, I often want to
track the other way and find out who sent a particular file in my
attachment's folder, and when.

Or, at least, it *would* be really useful if it were not for the fact
that the script does not fire. PM appears to not activate applescripts
if they are called automatically by a filter, as mine is (the condition
is set to [Attachment > 0k] which I know works as a trigger because I
also use it in another filter to set the label colour for messages with
attachments. That other filter works fine.

This is not the first time I've flagged this problem (it's been plaguing
me for several years now), but despite many versions of PM coming and
going, it seems never to have been fixed. It must be seen as a bug, surely?

Is it just me?
Rick

--
G5 2GHz x2  ::  2GB RAM  ::  10.4.7  ::  PM 5.5.2  ::  3 pane mode

Shark Attack: A Design Studio
<www.sharkattack.co.uk>

--
Original message:
Received from Alan Harper on 22/4/07 at 14:40

>I can confirm that I also do NOT have this problem (perhaps you are the
>only one!) One thing I love about PowerMail is that it usually can track
>an attachment link even after I move the attachment to another folder
>and rename the file. (Though I usually have to quit and relaunch the
>program). I assume it uses aliases to track attachments.


----------------------------------------------------------------------

Subject: Re: Applescript not triggering, WAS Attachment link failing
From: "Tim Hodgson" <[EMAIL PROTECTED]>
Date: Mon, 23 Apr 2007 10:12:59 +0100

On Mon, Apr 23, 2007 at 9:56 am +0100, Rick Lecoat wrote:

>Or, at least, it *would* be really useful if it were not for the fact
>that the script does not fire. PM appears to not activate applescripts
>if they are called automatically by a filter, as mine is (the condition
>is set to [Attachment > 0k] which I know works as a trigger because I
>also use it in another filter to set the label colour for messages with
>attachments. That other filter works fine.

I don't think the problem is that "PM appears to not activate
applescripts if they are called automatically by a filter"; I have
several filters that call an Applescript to trigger a Growl
notification, and they work fine.

Sorry I can't help further, but maybe that narrows it down a bit.
--
TimH

PowerMail 5.5.2 (build 4475) | OS X 10.4.9 | PowerBook FW/500 | 1GB RAM


----------------------------------------------------------------------

Subject: Re: Applescript not triggering, WAS Attachment link failing
From: "Rick Lecoat" <[EMAIL PROTECTED]>
Date: Mon, 23 Apr 2007 10:41:47 +0100

Okay Tim, thanks.

Maybe the script is just too old then. Like I said, I have no
applescript skills at all, so I can't diagnose whether it might be the
script that has fallen behind the PM library.

Here, then, is the full code of it, complete with comments and notes:

. . . . . . . . . .

(* tag attachments v1.0 is tested against powermail 3.1.1 on os x 10.1.2 *)
(* this will put identifying information into the comments of files *)
(* it looks for the attachments in the attachment folder, if the
attachment is not there *)
(* the script will put up a dialog telling you the file has moved. *)
(* use as a filter for incoming messages *)

(* includes, sender display name and email, message subject, and date sent *)

(* many thanks to tim lisauskas for helping debug this script *)


property pmSender : ""
property pmID : ""
property pmSubject : ""
property pmContent : ""
property pmTimeSent : ""
property pmDisplayName : ""
property pmAddress : ""
property pmAttach : ""
set x to 0

tell application "PowerMail"
        try
                set pmAttach to attachment folder
                
                set theMessages to the current messages
                repeat with msg in theMessages
                        set pmSender to sender of msg
                        --return pmSender
                        set pmAddress to email address of pmSender as string
                        --return pmAddress
                        set pmDisplayName to display name of pmSender as string
                        --return pmDisplayName
                        set pmSubject to subject of msg as string
                        set pmTimeSent to time sent of msg as string
                        set pmID to ID of msg as integer
                        set pmAttachments to name of attachments of msg as list
                        -- New code by Wayne Brissette
                        -- Check to see if attachment exists
                        set MyAttachment to item 1 of pmAttachments as string
                        if MyAttachment is "" then
                                set HasAttachment to false
                        else
                                set HasAttachment to true
                        end if
                        --- End of new code by Wayne Brissette
                        --return pmAttachments
                        
                        if length of pmAttachments > 1 then
                                set numAttach to length of pmAttachments
                                repeat with i from 1 to numAttach
                                        tell application "Finder"
                                                try
                                                        set x to x + 1
                                                        set theAttach to item x 
of pmAttachments as text
                                                        if ((file theAttach of 
folder pmAttach) exists) is true then
                                                                set 
pmAttachFile to ((file theAttach of folder pmAttach) as alias)
                                                                my 
tagAttachment(pmAttachFile)
                                                        else
                                                                tell 
application "PowerMail"
                                                                        display 
dialog "The attachment " & theAttach & " has been moved
since download." with icon 2 buttons {"OK"} default button 1
                                                                end tell
                                                        end if
                                                end try
                                        end tell
                                end repeat
                        else
                                tell application "Finder"
                                        set pmAttachments to item 1 of 
pmAttachments as text
                                        if ((file pmAttachments of folder 
pmAttach) exists) is true then
                                                set pmAttachFile to ((file 
pmAttachments of folder pmAttach) as alias)
                                                my tagAttachment(pmAttachFile)
                                        else if HasAttachment is true then -- 
New else statement by Wayne
Brissette
                                                tell application "PowerMail"
                                                        display dialog "The 
attachment has been moved since download."
with icon 2 buttons {"OK"} default button 1
                                                end tell
                                        end if
                                end tell
                        end if
                end repeat
                
        on error errMsg number errNum
                beep
                display dialog "error: " & errNum & return & errMsg
                return
        end try
        
        
end tell

on tagAttachment(whatFile)
        try
                set msgTag to "From: " & pmDisplayName & " <" & pmAddress & ">" 
& return & ¬
                        "Subject: " & pmSubject & return & "Date Sent: " & 
pmTimeSent as string
                
                tell application "Finder"
                        --select file whatFile
                        set the comment of whatFile to msgTag
                end tell
        end try
end tagAttachment


(* comments or suggestions *)
(* [EMAIL PROTECTED] *)
(* http://www.hells-half-acre.com/ *)

(* scripts hosted at the powermail applescript archive *)
(* http://homepage.mac.com/wayneb/powermail.html *)

. . . . . . . . . .


--
G5 2GHz x2  ::  2GB RAM  ::  10.4.7  ::  PM 5.5.2  ::  3 pane mode

--
Original message:
Received from Tim Hodgson on 23/4/07 at 10:12

>I don't think the problem is that "PM appears to not activate
>applescripts if they are called automatically by a filter"; I have
>several filters that call an Applescript to trigger a Growl
>notification, and they work fine.
>
>Sorry I can't help further, but maybe that narrows it down a bit.


----------------------------------------------------------------------

Subject: Re: Applescript not triggering, WAS Attachment link failing
From: "cheshirekat" <[EMAIL PROTECTED]>
Date: Mon, 23 Apr 2007 06:49:08 -0600

On Mon, Apr 23, 20079:56 AM, the following words from Rick Lecoat
[EMAIL PROTECTED], emerged from a plethora of SPAM ...

>I have an apple script (not written by me -- I have no skills in that
>arena) that is supposed to fire any time a message comes in with an
>attachment. The script writes to the attached file's Finder comments
>(are they still called Finder Comments?), making a note of who sent the
>file and the date. This is really useful because, although I also have
>had no problem with PM losing the links to attachments, I often want to
>track the other way and find out who sent a particular file in my
>attachment's folder, and when.
>
>Or, at least, it *would* be really useful if it were not for the fact
>that the script does not fire. PM appears to not activate applescripts
>if they are called automatically by a filter, as mine is (the condition
>is set to [Attachment > 0k] which I know works as a trigger because I
>also use it in another filter to set the label colour for messages with
>attachments. That other filter works fine.

Is your filter at the end of your list of filters, or where is it
located? To act on all attachments received, it would need to be at or
near the top of your list of filters. Or, at least should not follow any
scripts that move the attachments.

Does the script run properly if you manually run that filter on your
messages that have attachments? Have you tried copying the entire
contents of the script into a new script file and saving? (Don't delete
the original too quickly, but the AppleScript Editor would probably tell
you if there was a syntax error with the script you have been using, or
trying to use.)

I'm not sure if this helps, since I really don't get many attachments
that aren't spam these days to test with, but try the script below (It's
similar to a script I wrote for manual use and modified slightly for
your use.):

<Begin AppleScript>

property ret : return

to addToFileComments from {aliasList, sn, sea, stime, sub}
   set the newComment to "From: " & sn & " <" & sea & ">" & ret & "Date:
" & stime & ret & "Subject: " & sub
   tell application "Finder"
      repeat with af in the aliasList
         if the af's comment is "" then
            set the af's comment to the newComment
         else
            set the oldc to the af's comment
            set the af's comment to the oldc & ret & the newComment
         end if
      end repeat
   end tell
end addToFileComments

tell application "PowerMail"
   set the msgList to the current messages
   if the msgList is not {} then
      repeat with theMsg in the msgList
         set the msgSender to theMsg's sender
         set {the senderName, the senderEAddress} to {msgSender's
display name, msgSender's email address}
         set the msgSubject to theMsg's subject
         set the msgSentTime to theMsg's time sent as text
         set the attachmentList to theMsg's attachments

         if not the attachmentList is {} then
            set the filesToMark to {}
            repeat with attachedF in the attachmentList
               set the attachedFile to the attachedF's file
               set the end of the filesToMark to the attachedFile
            end repeat
            addToFileComments of me from {filesToMark, senderName,
senderEAddress, msgSentTime, msgSubject}
         end if
      end repeat
   end if
end tell

<End AppleScript>

Hope this helps. I don't have any scripts that trigger AppleScripts
because PM's filters fit most of my needs. I have AppleScripts that I
use manually for other instances. If you don't get a lot of attachments,
you can manually run your script, or the above script on individual
messages, or several messages at once, or even an entire folder of
messages if the script works for you outside a filter.

Good luck!

--
A nation creates music--the composer only arranges it.
-  Mikhail Glinka (1804-1857), Russian composer. Quoted in Theatre Arts
Magazine (New York, June 1958).

* MAC PRO 2 GHz Quad Xeon * OS X 10.4.9 * 3 GB Ram *


----------------------------------------------------------------------

Subject: Re(2): Applescript not triggering, WAS Attachment link failing
From: "Winston Weinmann" <[EMAIL PROTECTED]>
Date: Mon, 23 Apr 2007 09:07:34 -0400

Rick -

Please let us know if this script works.

chesirekat - Thanks!


- Winston


cheshirekat wrote:

>On Mon, Apr 23, 20079:56 AM, the following words from Rick Lecoat
>[EMAIL PROTECTED], emerged from a plethora of SPAM ...
>
>>I have an apple script (not written by me -- I have no skills in that
>>arena) that is supposed to fire any time a message comes in with an
>>attachment. The script writes to the attached file's Finder comments
>>(are they still called Finder Comments?), making a note of who sent the
>>file and the date. This is really useful because, although I also have
>>had no problem with PM losing the links to attachments, I often want to
>>track the other way and find out who sent a particular file in my
>>attachment's folder, and when.
>>
>>Or, at least, it *would* be really useful if it were not for the fact
>>that the script does not fire. PM appears to not activate applescripts
>>if they are called automatically by a filter, as mine is (the condition
>>is set to [Attachment > 0k] which I know works as a trigger because I
>>also use it in another filter to set the label colour for messages with
>>attachments. That other filter works fine.
>
>Is your filter at the end of your list of filters, or where is it
>located? To act on all attachments received, it would need to be at or
>near the top of your list of filters. Or, at least should not follow any
>scripts that move the attachments.
>
>Does the script run properly if you manually run that filter on your
>messages that have attachments? Have you tried copying the entire
>contents of the script into a new script file and saving? (Don't delete
>the original too quickly, but the AppleScript Editor would probably tell
>you if there was a syntax error with the script you have been using, or
>trying to use.)
>
>I'm not sure if this helps, since I really don't get many attachments
>that aren't spam these days to test with, but try the script below (It's
>similar to a script I wrote for manual use and modified slightly for
>your use.):
>
><Begin AppleScript>
>
>property ret : return
>
>to addToFileComments from {aliasList, sn, sea, stime, sub}
>   set the newComment to "From: " & sn & " <" & sea & ">" & ret & "Date:
>" & stime & ret & "Subject: " & sub
>   tell application "Finder"
>      repeat with af in the aliasList
>         if the af's comment is "" then
>            set the af's comment to the newComment
>         else
>            set the oldc to the af's comment
>            set the af's comment to the oldc & ret & the newComment
>         end if
>      end repeat
>   end tell
>end addToFileComments
>
>tell application "PowerMail"
>   set the msgList to the current messages
>   if the msgList is not {} then
>      repeat with theMsg in the msgList
>         set the msgSender to theMsg's sender
>         set {the senderName, the senderEAddress} to {msgSender's
>display name, msgSender's email address}
>         set the msgSubject to theMsg's subject
>         set the msgSentTime to theMsg's time sent as text
>         set the attachmentList to theMsg's attachments
>
>         if not the attachmentList is {} then
>            set the filesToMark to {}
>            repeat with attachedF in the attachmentList
>               set the attachedFile to the attachedF's file
>               set the end of the filesToMark to the attachedFile
>            end repeat
>            addToFileComments of me from {filesToMark, senderName,
>senderEAddress, msgSentTime, msgSubject}
>         end if
>      end repeat
>   end if
>end tell
>
><End AppleScript>
>
>Hope this helps. I don't have any scripts that trigger AppleScripts
>because PM's filters fit most of my needs. I have AppleScripts that I
>use manually for other instances. If you don't get a lot of attachments,
>you can manually run your script, or the above script on individual
>messages, or several messages at once, or even an entire folder of
>messages if the script works for you outside a filter.
>
>Good luck!
>
>--
>A nation creates music--the composer only arranges it.
>-  Mikhail Glinka (1804-1857), Russian composer. Quoted in Theatre Arts
>Magazine (New York, June 1958).
>
>* MAC PRO 2 GHz Quad Xeon * OS X 10.4.9 * 3 GB Ram *
>
>



----------------------------------------------------------------------
End of powermail-discuss Digest

Reply via email to