(Prev Next) Part of UserLand's MIDAS Website. Wednesday, August 27, 1997.

Mail Framework

Here's a listing of all the important pieces of the Mail Agent framework as implemented in Frontier.

  1. suites.mail.init

    if double (string.mid (Frontier.version (), 1, 3)) < 4.1
    scriptError ("The mail suite requires Frontier 4.1 or greater.")
    if not defined (user.mail)
    new (tabletype, @user.mail)
    if not defined (user.mail.agents)
    new (tabletype, @user.mail.agents)
    user.mail.agents.defaultFilter = mail.traps.defaultFilter
    if not defined (user.mail.prefs)
    new (tabletype, @user.mail.prefs)
    if not defined (user.mail.prefs.msgcount)
    user.mail.prefs.msgcount = 0
    if not defined (user.mail.prefs.enabled)
    user.mail.prefs.enabled = false
    if not defined (system.verbs.traps.CSOm)
    new (tabletype, @system.verbs.traps.CSOm)
    if not defined (system.verbs.traps.CSOm.eNot)
    system.verbs.traps.CSOm.eNot = mail.traps.CSOmeNot
    if not defined (system.startup.mail)
    system.startup.mail = mail.traps.startup
    if not defined (system.shutdown.mail)
    system.shutdown.mail = mail.traps.shutdown

  2. mail.traps.defaultFilter

    on defaultFilter (mailerappname, whatEvent, theList)
    «this is the default mail filter script
    «it just displays the message counter in Frontier's main window
    «we'll leave it to later (and others) to provide cool mail filters
    «whatEvent can take on the following values:
    «wHCn - hasConnected
    «wArv - mailArrives
    «wSnt - mailSent
    «wFil - opensFilters
    «wWcn - willConnect
    local (directionstring)
    case whatEvent «we only handle in and out events
    'wHCn'
    'wFil'
    'wWcn'
    return (true)
    'wArv'
    directionstring = "in"
    'wSnt'
    directionstring = "out"
    if sizeof (thelist) > 0 «for debugging, if there's a problem we can repeat it in debugger
    scratchpad.enotlist = theList
    local (i, mailmsg)
    mail.otherRoot.open ()
    for i = 1 to sizeOf (theList)
    new (tabletype, @mailmsg)
    mailmsg.event = whatEvent
    mailmsg.direction = directionstring
    mailmsg.subject = ""
    mailmsg.date = ""
    mailmsg.recipient = ""
    mailmsg.cc = ""
    mailmsg.bcc = ""
    mailmsg.sender = ""
    mailmsg.text = ""
    mailmsg.msgnum = ++user.mail.prefs.msgcount
    mail.drivers.[mailerappname].getmessagetable (theList [i], @mailmsg)
    if mailmsg.date == ""
    mailmsg.date = clock.now ()
    msg (mailmsg.msgnum + " messages have passed thru user.mail.agents.")
    mail.otherRoot.close ()
    return (true)
    «bundle «test code
    «defaultFilter ("Eudora", 'wArv', scratchpad.enotlist)

  3. mail.traps.CSOmeNot

    on eNot (whatEvent, theList)
    mail.init ()
    local (i)
    for i = 1 to sizeOf (user.mail.agents)
    local (adr = @user.mail.agents [i])
    if typeOf (adr^) == scriptType
    adr^ ("Eudora", whatEvent, theList)
    return (true)

  4. mail.traps.startup

    mail.init ()
    if user.mail.prefs.enabled
    local (i)
    for i = 1 to sizeof (mail.drivers)
    try {mail.drivers [i].setNotification (true)}

  5. mail.traps.shutdown

    local (i)
    for i = 1 to sizeof (mail.drivers)
    try {mail.drivers [i].setNotification (false)}

  6. mail.enableFiltering

    on enableFiltering (fl) «if true, enable filtering; if false disable
    if user.mail.prefs.enabled == fl «nothing to do
    return
    user.mail.prefs.enabled = fl
    if fl «enabling
    mail.traps.startup ()
    else «disabling
    mail.traps.shutdown ()
    «bundle «test code
    «enableFiltering (true)

  7. suites.mail.drivers.Eudora.getMessageTable

    on getMessageTable (cookie, adrtable)
    local (s)
    with objectmodel, eudora, eventinfo
    s = get (cookie)
    «toys.newtextobject (s, @scratchpad.s) «for debugging
    on getline ()
    local (linestring = string.nthfield (s, cr, 1))
    s = string.delete (s, 1, sizeof (linestring) + 1)
    local (label, value)
    label = string.lower (string.nthfield (linestring, ":", 1))
    value = string.delete (linestring, 1, sizeof (label) + 2)
    bundle «special code that finds the text of the message
    if (sizeof (label) == 0) or (label contains cr)
    adrtable^.text = s
    return (false)
    case label
    "subject"
    "cc"
    "bcc"
    "date"
    adrtable^.[label] = value
    "to"
    adrtable^.recipient = value
    "from"
    adrtable^.sender = toys.cleanMailAddress (value)
    return (true)
    loop
    if not getline ()
    break
    if adrtable^.date == ""
    adrtable^.date = clock.now ()
    «bundle «test code
    «new (tabletype, @scratchpad.t)
    «getmessagetable (scratchpad.enotlist [1], @scratchpad.t)
    «edit (@scratchpad.t)
    «window.zoom (@scratchpad.t)

  8. suites.mail.drivers.Eudora.setNotification

    on setNotification (flturnon)
    if flturnon
    Eudora.turnNotificationOn ()
    else
    Eudora.turnNotificationOff ()


This page was last built with Frontier on a Macintosh on Wednesday, August 27, 1997 at 7:38:26 PM. Thanks for checking it out! Dave