Eudora and AppleScript Handbook by Scott Gruby Revision 1.0 ©1995 QUALCOMM, Inc. Introduction ------------------- Eudora's has the ability to be scripted such that repetitive tasks can be automated using AppleScript. Many, but not all, of Eudora's functions can be accessed allowing the user to create messages, check mail, as well as change settings from simple scripts. Note: This document assumes the user is using Eudora 1.5.1 or Eudora 2.1.1 or higher. Previous versions handled scripting differently. AppleScript Dictionary -------------------------- The commands that Eudora uses from AppleScript are documented in Eudora's AppleScript Dictionary; use the Script Editor to Open Dictionary and then choose Eudora. The commands will be listed as well as the parameters that they accept. Standard Commands -------------------- The simplest commands allow the user to create a new message, enter text (or extract text from a message), check for new mail, as well as message manipulations (transfer, forward, reply, etc.). The basic structure for AppleScript commands is: tell application "Eudora" end tell ************************************************** General Commands ************************************************** A script can tell Eudora to connect to the POP or SMTP server using the command: connect If no options are specified, the defaults from the Settings are used. The options are: with sending (without sending) which sends queued messages, with checking (without checking) which checks for mail, and with waiting (without waiting) which waits until Eudora is idle before connecting. If you want to launch Eudora from a script, you must have the Scriptable Finder (included with System 7.5 and System 7 Pro). You would use the following syntax: tell application "Finder" open {"Macintosh HD:Eudora Folder:Eudora" as alias} end tell If you want to open a particular settings file, the syntax would be identical, but you would substitute in the name and location of your settings file in the above example. ************************************************** Individual Message Commands (outgoing messages) ************************************************** The following illustrates the syntax for create a new message and entering data: tell application "Eudora" -- Create a new message in the out box make message at end of mailbox "out" -- Message 0 indicates the current message -- Set the recipient of the message set field "to" of message 0 to "username@hostname.com" -- Set who the message is from; -- This must be set to a valid address so that you can receive replies set field "from" of message 0 to "myname@hostname.com" -- set the subject of the message set field "subject" of message 0 to "The Subject" -- set the cc recipients of the message set field "cc" of message 0 to "cc@hostname.com" -- set the bcc recipients of the message set field "bcc" of message 0 to "bcc@hostname.com" -- set the body of the message -- field "" indicates the body of the message set field "" of message 0 to "This is the body of the message." -- Note: you can also use set body of message 0 to "This is the body." end tell The options, such as attachment encoding type, which signature to use, quoted printable, etc. (the items on the icon bar), can be set via AppleScript. The syntax is as follows: -- No Signature set signature of message 0 to none -- Regular Signature set signature of message 0 to standard -- Alternate Signature (Eudora 2.1) set signature of message 0 to alternate -- Use quoted printable encoding set QP of message 0 to true -- Request a return receipt on the message set return receipt of message 0 to true -- Wrap the text when it is sent set wrap of message 0 to true -- Tab expansion...tabs should be expanded to spaces set tab expansion of message 0 to true -- Keep a copy of the message after it is sent set keep copy of message 0 to true -- Macintosh Info should be sent with attachments set preserve macintosh info of message 0 to true -- Specify the attachment encoding...can be AppleDouble, AppleSingle, BinHex -- or uuencode (Eudora 2.1) set attachment encoding of message 0 to BinHex -- Set the priority of a message -- 0=Standard, 1=Highest, 120=High, 160=Low, 180=Lowest set priority of message 0 to 1 In order to attach documents to a message via AppleScript, you must have the full path name of the file(s) to attach. Use the following format: -- Attach file called "Macintosh HD:myFile" to current message set theName to "Macintosh HD: myFile" attach to message 0 documents {theName} You can attach several files to a message either by issuing multiple attach commands or specifying more than one filename in the {theName} section as follows: set theName to "Macintosh HD:myFile1" set theName2 to "Macintosh HD:myFile2" attach to message 0 documents {theName, theName2} The message can then be queued with the command: queue message 0 ************************************************** Individual Message Commands (incoming messages) ************************************************** With incoming messages, you can use many of the same types of commands as with the outgoing messages, but you can only get information, i.e. to get the subject of the message, you would use: get field "subject" of message 0 -or- set myField to field "subject" of message 0 This can be done for the following fields: "to", "cc", "from", "subject", "" (body), and priority. In addition you, can show all the header information (the Blah, Blah, Blah button) using: set show all headers of message 0 to true Messages can be forwarded, redirected, replied to, or transferred to a specific mailbox. Here's the syntax: -- Forwards a message quoting the entire message; -- A new message is created without a recipient forward message 0 -- Redirects a message -- A new message is created without a recipient redirect message 0 -- Replies to a message -- If you don't specify additional options, the default options -- (i.e. reply to all, etc.) will be used. The additional options -- are: with quoting (without quoting), with everyone (without -- everyone), and with self (without self). reply message 0 with quoting ************************************************** Changing Settings ************************************************** You can change many of Eudora's settings via a script. In order to do so, you must know the number of the setting you want to change. This information can be found in the Eudora Q&A stack which is location at: The general format for changing a setting is: set setting 3 to "popuser@hostname.com" Some common settings are: 3 POP Account 4 SMTP Server 5 Return address 6 Mail check interval 23 Ph Server 24 Save Password? 31 Password (if Save Password is on) 61 Dialup username 62 Dialup password (if Save Password is on) 77 Real name 84 Offline? ********************************************************************** Notification (telling Eudora to notify some other program or script) ********************************************************************** Eudora allows you the ability to notify an AppleScript when certain actions occur. For example, you can have it notify your paging application that new mail has arrived so that you are paged. You should not use the notification events from a script run from the Script Editor; this will cause Eudora to notify the Script Editor and not your script. Your script should be saved as an application and then it can be properly notified. In order to simplify the using notification, you should obtain the Notify-Kit which can be found at: This kit has scripts in it that allow you to drop your script onto them and either start or stop the notification. It also contains a sample script on what types of notifications are available, i.e. notify when mail is sent, mail arrives, is about to connect, or has finished connecting. ********************************************************************** More Help? ********************************************************************** If you need more help about scripting, you can join the Mac Scripting mailing list by sending email to: LISTSERV@DARTCMS1.DARTMOUTH.EDU with no subject line and the body of your message as follows: SUB MACSCRPT Your Name. If you want to remove yourself from the list, send email to the same address with the body as follows: SIGNOFF MACSCRPT If you are a user of the commercial version of Eudora, you can contact technical support for further assistance. Freeware users should consult various newsgroup that discuss scripting or use the mailing list indicated above. Comments about this document should be sent to: sgruby@qualcomm.com.