RE: Scripting Eudora
RE: Scripting Eudora
- Subject: RE: Scripting Eudora
- From: Russ Cusimano <email@hidden>
- Date: Thu, 8 Feb 2001 09:01:56 -0800
Dale Saukerson <email@hidden> wrote:
Can someone point me towards some docs or offer some sample code for
scripting Eudora?
I'm still a rookie and barely understand how to put together syntax
to interpret/use the dictionary.
The Qualcomm web site has several resources and links. I have sent you
privately a couple references gleaned from those sources. The Eudora
library is, generally, complex and takes quite a bit of experimentation.
Here are some examples of Eudora scripts I have written.
1. Sets the SMTP server to <smpt.mindspring.com>. Used when switching
between ISPs
tell application "Eudora"
set n to count personalities
repeat with x from 1 to n
set setting 4 of personality x to "smtp.mindspring.com"
end repeat
end tell
2. Sets the SMTP server based on input from a dialog
display dialog "Enter an SMTP server name or IP address" default answer
"alterdial.uu.net"
set choice to (text returned of result)
tell application "Eudora"
set n to count personalities
repeat with x from 1 to n
set setting 4 of personality x to choice
end repeat
end tell
3. Copys all the contacts from a specific address book (folder) into a
new message. Used to export those addressed to another application. In my
case, people subscribe to our mailing list using a form on our web site.
Those subscription addresses come to me via Eudora and create new
contacts in the address book. When it's time to send an announcement to
the mailing list, I export all contacts for use in an email merge
application called eMerge.
set block to ""
tell application "Eudora"
set namenumber to count the addresses in nickname file "DRS
Mailing List"
set namenumber to namenumber - 1
repeat with x from 0 to namenumber
set tempaddress to addresses of nickname x of nickname file
"DRS Mailing List"
set tempname to nickname of nickname x of nickname file "DRS
Mailing List"
set block to block & tempaddress & tab & tempname & return
end repeat
make new message at end of mailbox "Out"
set field named "subject" of message 0 to "DRS export for eMerge"
set body of message 0 to block
save message 0
end tell
4. Steps through a mail box, appending part of the subject and the sender
to a list for export. We register softball players through a league web
site and form results come to me and the league registrar for processing.
At the end of the registration period, I use this script to make a list
of all the players, parents, and email addresses. This CSV list can be
mailed to someone else and imported into their address book to create a
group.
set block to "player,email,parent" & return
display dialog "Exact name of the mailbox to list" default answer "SGS
Spring 2001 Registration"
set targetBox to (text returned of result)
tell application "Eudora"
set registrantNumber to count the messages in mailbox targetBox
repeat with x from 1 to registrantNumber
set tempSender to field named "from" of message x of
mailbox targetBox
set tempSubject to subject of message x of mailbox targetBox
set trimmedSubject to trimSubject(tempSubject) of me
set trimmedSender to trimSender(tempSender) of me
set block to block & trimmedSubject & "," & trimmedSender
& return
end repeat
make new message at end of mailbox "Out"
set body of message 0 to block
set field named "subject" of message 0 to "Players Registered Online"
save message 0
end tell
on trimSubject(subjectText)
if (subjectText contains "Spring") then
set startPosition to (offset of "Spring" in subjectText) + 7
else
if (subjectText contains "Winter") then
set startPosition to (offset of "Winter" in subjectText)
+ 7
end if
end if
set subjectText to (text startPosition thru (count subjectText) of
subjectText)
return subjectText
end trimSubject
on trimSender(senderText)
set senderText to (text 7 thru (count senderText) of senderText)
set firstParen to (offset of "(" in senderText)
set senderText to (text 1 thru (firstParen - 2) of senderText) & "," &
(text (firstParen + 1) thru ((count senderText) - 1) of senderText)
return senderText
end trimSender
5. Add-a-spammer. Add the address of this (selected) message to a
contact group named "*Known Spammers 2," and move the message to the
mailbox named "Spam." A Eudora filter compares all incoming mail to the
nickname. So, once your address is added to that nickname, all future
mail from you is sent straight to the Spam mailbox by the filter. I
created the nickname "*Known Spammers 2" after "*Known Spammers 1" became
too long for Eudora to use (about 800 nicknames, I think). "KS backup" is
necessary because when some mangled addresses cause the script execution
bomb, the contents of the known spammers nickname are lost.
tell application "Eudora"
set tempAddresses to addresses of nickname "*Known Spammers 2"
set addresses of nickname "*KS backup" to tempAddresses --just in case
set oldSpammer to field "from" of message 0
set newSpammer to trimSpammer(oldSpammer) of me
set addresses of nickname "*Known Spammers 2" to addresses of nickname
"*Known Spammers 2" & "," & newSpammer
--set subject of message 0 to "spam"
set status of message 0 to "read"
move message 0 to end of mailbox "Spam"
end tell
on trimSpammer(fromText)
if (fromText starts with "From:") then
set fromText to (text 6 thru (count fromText) of fromText)
end if
if (fromText contains "<") then
set startPosition to (offset of "<" in fromText) + 1
set fromText to (text startPosition thru ((count fromText) -
1) of fromText)
end if
if (fromText contains ",") then
set startPosition to 1
set fromText to (text startPosition thru ((offset of "," in
fromText) - 1) of fromText)
end if
return fromText
end trimSpammer--
Russ