Re: SpamCop script which worked in Tiger suddenly dropping some attachments in Leopard
Re: SpamCop script which worked in Tiger suddenly dropping some attachments in Leopard
- Subject: Re: SpamCop script which worked in Tiger suddenly dropping some attachments in Leopard
- From: Kok-Yong Tan <email@hidden>
- Date: Mon, 7 Feb 2011 12:14:34 -0500
On Mon, Feb 7, 2011, at 07:45, Axel Luttgens wrote:
Le 6 févr. 2011 à 23:58, Kok-Yong Tan a écrit :
I picked up a script that basically takes selected spams, processes
them by expanding them with full headers to a folder on my desktop,
attaches each of them to an email and sends them to a quick
reporting address at spamcop.net. This used to work fine in Tiger
Mail but did so very slowly. Now that I'm using the same script on
Leopard (10.5.8) Mail, it works much faster (maybe an order of
magnitude) but periodically (not always), it'll drop attachments.
By this, I mean that if there were say, 8, attachments, it'll only
attach the first to the third, drop the fourth to the seventh and
attach the eighth to the email. Usually when Apple Mail is busy
downloading new mail but sometimes when Apple Mail is seemingly
idle according to the Activity window. I then have to manually
attach the missing fourth to seventh attachments. Can anyone tell
me why a script that worked perfectly in Tiger is now behaving like
this in Leopard? Can anyone tell me how to fix it? Since it
doesn't crash, it doesn't quite highlight in the Script Editor
debugging window as to what the problem is. I've tried making it
a standalone app as well as adding a delay of 2 to 3 seconds at the
attachment section of the Applescript but neither seems to have
helped. It can occur with 20 emails. It can occur with 5 emails.
The dropouts seem to be very random.
Hello,
I couldn't reproduce those dropouts here, but I'm on 10.6.6.
Now, it seems that some operations are performed more or less
asynchronously, especially the "make new attachment" one. Add to
this the legendary fuzzy behavior of Mail's outgoing messages, and
you've got a nice recipe... ;-)
That said, perhaps could you try a slight variant of the main loop
of your script:
set counter to counter + 1
set sourceFilePath to ((theOutputFolderPath & theNewFolderName as
string) & ":ml" & counter & ".src")
set thisSource to the source of thisMessage
set totalSize to totalSize + (length of thisSource)
tell me
set f to open for access file sourceFilePath with write permission
tell me to write thisSource to f
close access f
set theAttachment to alias sourceFilePath
end tell
make new attachment with properties {file name:theAttachment} at
after last character of content of theMessage
delete thisMessage
and see whether you get more reliable results. At the very least,
the events log should be more readable and thus possibly provide
better clues about what's going wrong.
HTH,
Axel
Many thanks, Axel. I've typed it in and it seems to run fine after I
corrected the variable "sourceFilePath" above to "sourceFile" as the
former isn't defined. As I mentioned in my original email, even with
Leopard 10.5.8 Mail, the dropouts only happen sporadically so it's not
a consistently reproducible problem (which makes debugging all that
much harder). I'll try running your version for a while from within
the Script Editor for debugging purposes and see if the same problem
crops up again. I'll report back over the next couple of weeks or so.
Tan
--
Reality Artisans, Inc. # Network Wrangling and Delousing
P.O. Box 565, Gracie Station # Apple Certified Consultant
New York, NY 10028-0019 # Apple Consultants Network member
<http://www.realityartisans.com> # Apple Developer Connection member
(212) 369-4876 (Voice) # My PGP public key can be found
at <https://keyserver.pgp.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden