Digest archiving
Digest archiving
- Subject: Digest archiving
- From: Cornwall <email@hidden>
- Date: Sun, 11 Nov 2001 13:34:24 -0800
I thought I might share a script for archiving this lists digests.
It's written for Eudora 4.3.3, and presumes you receive the digest as
a MIME attachment. The script also presumes the digests are all in a
particular mailbox. I have tested it with OS 9.1, 9.2.1 and OSX 10.1
running it under classic. I am working on a script to do the same
thing with Mail for X, but I have a looong way to go.
Requires a FMP database with the correct fields in the correct order.
Watch out for line wraps and for the one continuation character
(option L)
It is written to run from OSA Menu. Do *NOT* run it from the
Eudora OSA gismo.
Cheers
Corny
tell application "Eudora"
set digestCnt to count of every message of mailbox "AS Users Digest"
if digestCnt is 0 then return
set EuTrash to file of mailbox 3 -- Empty trash,JD's example
end tell
tell application "Finder" to delete EuTrash
open for access EuTrash
close access EuTrash
tell application "Mac HD:Applications (Mac OS 9):FileMaker Pro 5 Folder:FileMaker Pro"
-- I have more than one version of FMP and I need to use this version
-- Otherwise, you can just use: tell app "FileMaker Pro"
activate
if not (exists database "AppleScript Users Digests") then
open alias "Mac HD:Applications (Mac OS 9):Apple Extras:AppleScript:AppleScript Users Digests :AppleScript Users Digests"
end if
go to database "AppleScript Users Digests"
--in case this database was already open and under other databases
end tell
tell application "Eudora" to activate
repeat with i from 1 to digestCnt
tell application "Eudora"
subject of first message of mailbox "AS Users Digest"
--Shorten the message's subject to use it as a file name for the issue
--of the attached digest (mailbox)
set parsed to result's text items 27 thru -10 as text
if last character of parsed is " " then set parsed to text items 1 thru -2 of parsed as text
"AS-users digest, " & parsed returning issue -->e.g. "AS-users digest, Vol 2 #1022"
tell first message of mailbox "AS Users Digest"
set thisMsgsAttchDigest to attachment 1
--a Eudora mailbox usually named "Untitled #" ("#" = some number)
set thisMsgsAttchDigest to thisMsgsAttchDigest as alias
end tell
move first message of mailbox "AS Users Digest" to (end of mailbox "Trash")
end tell
tell application "Finder"
--move the attached digest out of the "Attachments folder" to an archive location
move thisMsgsAttchDigest to folder "Mac HD:Applications (Mac OS 9):Apple Extras:AppleScript:AppleScript Users Digests :"
set the name of thisMsgsAttchDigest to issue
--rename "Untitled" mailbox to issue name -->e.g. "AS-users digest, Vol 2 #1022"
open thisMsgsAttchDigest --open the attached digest in it's own window
end tell
tell application "Eudora"
set currentMailbox to name of window 1 --define what we will be talking to
set CurDigestsMsgCnt to count of every message of mailbox currentMailbox
end tell
repeat with i from 1 to CurDigestsMsgCnt
--go through every message of the attached digest, putting data from each message
--into its own FMP record, and then moving that message to the trash
(*This next part is slower than it might be. However, for my
own needs, I want the data in two different forms, and in two different
places. I'm also picky about the final message order of the attached
digest. It takes two separate moves of each message to get them
correctly scrambled. No moves are needed if they're only going to
FMP. (I wish Eudora could move a message to the beginning of a
mailbox!!) *)
tell application "Eudora" --get my data for FMP into variables
tell first message of mailbox currentMailbox
set {fromField, theSubject, sendersDate, relativeDate, messageBody} to , --option L char
{field "From", its subject, universal seconds, field "Date", body}
end tell
move first message of mailbox currentMailbox to (end of mailbox "Trash") --just visiting
end tell
(*Clean up the data for FileMaker Pro*)
set trimFromFieldName to text 7 through -1 of fromField as string
if the first word of theSubject is "Re" then set theSubject to ,
(text 5 thru -1 of theSubject) as string
set trimRelativeDate to text 7 through -1 of relativeDate as string
--Emmanuel Levy's "numeric" method for getting the month integer quickly
copy sendersDate to b
set month of b to January
set x to 1 + ((sendersDate - b + 1314864) div 2629728) --> the month's integer
set shortMessageDate to (x as text) & "/" & day of sendersDate & "/" & ,
text -4 thru -1 of (year of sendersDate as text)
set messageTime to the time string of sendersDate
(*Get all the data into a list*)
set tempDataList to {trimFromFieldName, theSubject, trimRelativeDate, messageBody, ,
shortMessageDate, messageTime}
tell application "FileMaker Pro"
set newRec to (create new record with data tempDataList ,
at end of layout "Set Fields" of database 1) --give the list to FMP
end tell
end repeat
(*Put the digest back together*)
repeat with i from 1 to (CurDigestsMsgCnt + 1)
tell application "Eudora" to move first message of mailbox "Trash" to (end of mailbox currentMailbox)
end repeat
tell application "Eudora" to close window 1
end repeat
tell application "FileMaker Pro" to go to newRec --go to the last new record
set tempDataList to {"", "", "", "", "", ""}