Entourage X script keeps growing
Entourage X script keeps growing
- Subject: Entourage X script keeps growing
- From: Christopher Slye <email@hidden>
- Date: Tue, 13 Aug 2002 08:48:35 -0700
Hi there. Attached below is an Entourage X script I wrote to create email
digests. I continue to be perplexed by its tendency to grow -- and by that I
mean the actual script file changes in size. When freshly-saved, the script
is about 20 KB or so, but I've seen it end up as large as 1 MB. Sometimes
the size doesn't change much, but the modification date always updates.
I actually don't even know why the script's modification date is changing. I
have other scripts which remain un-modified no matter how much they're run,
but this one seems to like to retain its data somewhere. It doesn't use any
properties -- not intentionally anyway -- and I thought that was the only
reason for a script to be remembering its variables. It obviously can be
handling some very large pieces of data as it collects emails together.
I have a feeling the reason will be obvious to some veteran AppleScripter.
I'm one of those people who can deal perfectly with Perl and the like, but
get frustrated by AppleScript because its behavior seems so much less
predictable and its documentation less reliable.
By the way, I've had this script and the problem since Outlook Express on OS
9, so it doesn't seem to be related to the app or the OS version.
Thanks for any help.
Christopher
p.s. Sorry for the sporadic and semi-helpful script comments.
---
set AppleScript's text item delimiters to {""}
set MsgList to {}
set DigestOut to {} -- The entire digest
set SubjectList to {} -- List for Summary subject
set MsgNumber to 0 -- The message counter
set MsgSeparator to "
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-="
tell application "Microsoft Entourage"
set MsgList to (get current messages)
repeat with Msg in MsgList
set MsgOut to {} -- Clear the list to hold the parts of message text
set MsgNumber to MsgNumber + 1
copy ("[" & MsgNumber & "]" & return) as string to end of MsgOut
-- Collect sender information:
set MsgFrom to {}
if display name of sender of Msg is not "" then copy (display name
of sender of Msg) to end of MsgFrom
copy ("<" & address of sender of Msg & ">") to end of MsgFrom
set AppleScript's text item delimiters to " "
set MsgFrom to MsgFrom as string
copy ("From: " & MsgFrom) to end of MsgOut
-- Collect date information:
copy ("Date: " & (time sent of Msg as string)) to end of MsgOut
-- Collect recipient information:
set MsgTo to {} -- All recipient info collected here
set MsgToTo to {}
set MsgToCC to {}
set MsgToBC to {}
set MsgToNG to {}
repeat with X in (recipients of Msg)
set MsgToName to {}
if (display name of address of X) is not "" then copy (display
name of address of X) to end of MsgToName
copy ("<" & address of address of X & ">") to end of MsgToName
set AppleScript's text item delimiters to " "
set MsgToName to MsgToName as string
set AppleScript's text item delimiters to ""
set MsgToType to (recipient type of X as string)
if MsgToType is "to recipient" then copy MsgToName to end of
MsgToTo
if MsgToType is "cc recipient" then copy MsgToName to end of
MsgToCC
if MsgToType is "bcc recipient" then copy MsgToName to end of
MsgToBC
if MsgToType is "newsgroup recipient" then copy MsgToName to end
of MsgToNG
end repeat
set AppleScript's text item delimiters to ", "
if MsgToTo is not {} then copy ("To: " & (MsgToTo as string)) to end
of MsgTo
if MsgToCC is not {} then copy ("Cc: " & (MsgToCC as string)) to end
of MsgTo
if MsgToBC is not {} then copy ("Bcc: " & (MsgToBC as string)) to
end of MsgTo
set AppleScript's text item delimiters to return
set MsgTo to MsgTo as string
copy MsgTo to end of MsgOut
-- Collect subject information:
copy ("Subject: " & subject of Msg) to end of MsgOut
copy subject of Msg to end of SubjectList
-- Collect content
copy return to end of MsgOut -- The space between header and content
copy content of Msg to end of MsgOut
-- Collect attachment information:
set MsgAttach to {}
repeat with X in (attachments of Msg)
copy (name of X) to end of MsgAttach
end repeat
if MsgAttach is not {} then
set AppleScript's text item delimiters to ", "
set MsgAttach to ("Attachments: " & (MsgAttach as string))
set AppleScript's text item delimiters to return
copy "" to end of MsgOut -- The space above attachment text
copy MsgAttach to end of MsgOut
end if
set AppleScript's text item delimiters to return
copy (MsgOut as string) to end of DigestOut
set AppleScript's text item delimiters to ""
copy MsgSeparator to end of DigestOut
end repeat
-- Summarize subjects
copy MsgSeparator to beginning of DigestOut
repeat with n from (length of SubjectList) to 1 by -1
set SubjSummary to (n & ". " & (item n of SubjectList)) as string
if length of SubjSummary > 80 then ,
set SubjSummary to (characters 1 through 80 of SubjSummary) as
string
copy SubjSummary to beginning of DigestOut
end repeat
end tell
tell application "BBEdit 6.5"
activate
-- Create a new BBEdit document
set DigestName to (text returned of (display dialog "Name the email
digest:" default answer "") & ".txt")
make new document with properties {name:DigestName}
set Digest to window of document DigestName
set AppleScript's text item delimiters to return
set text of Digest to (DigestOut as string)
end tell
set DigestOut to {}
set text item delimiters to {""}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.