Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Submitted for your approval.

From: edanaii:cox at: 5-Aug-2002 18:57

All, Here's a REBOL program I've been working on. It's almost complete, but I still have a few things to do to it. Since this is my first *serious* REBOL program, I'm submitting here for you to critique. Please feel free to tear it apart. One of the things I have not added is error handling. I'd also like advice on that, like what can go wrong. I know for example that when I try to open the mailbox, it may not be there. Naturally, I need to trap that. What other events do I need to keep an eye on in order to manage the mailbox? Thanks in advance... ====================================================================== REBOL [ Title: "Remailer for mailbox" File: %Mail.r Date: 01-Jun-2002 Purpose: { Processes the mailbox and distributes emails based on the Subject Line found. Will route to multiple emails and pagers depending on need. } Note: { Will remove all emails it finds from the specified mailbox and store them in a text document. } Category: [email] ] Mail: Make Object! [ End: Func [ MBX [Port!] ] [ Close MBX ] Format: Func [ LTR [Object!] ] [ ;> Temp fix, whitespace in 66 all [ LTR/Header/subject/66 = #" " remove at LTR/subject 66 ] LTR/Body: Join Mail_Body_Pre LTR/Header/Content LTR/Body: Join LTR/Body Mail_Body_Post Return LTR ] Process: Func [ MBX [File!] ] [ { This function starts the entire mail process. It requires a mailbox to open, scans the mailbox, and then wraps up the program. } Inbox: Mail/Start MBX Mail/Scan Inbox Mail/End Inbox ] Rules: Func [ LTR [Object!] ] [ "Performs the rule-based processing of the specified mailbox." ; Are we ready to send this email? Send_It: False ; Get latest Rules and Contacts. Do %Contact_List.r Do %Mail_Rules.r ; Compare the Subject Line of the eMail with our Rules ; When the Subject Line matches what is in the Rule Book ; Then perform the action identified there. ForEach Rule Rule_Book/List [ If find LTR/Header/Subject Rule/Subject_Text [ Do Rule/Action Print [ "=" Rule/Subject_Text ">" Rule/Action ] ; Compare the Escalation level of the email with our Rule. ; If the Escalation level is greater than/equal to our Rule. ; Perform the necessary Action to escalate the message. If Rule/Escalation [ ForEach Response Response_Group/List [ If Response/Level >= Rule/Escalation/Level [ Do Rule/Escalation_Action Break ] ] ] ] ] ] Scan: Func [ MBX [Port!] ] [ "Scans the mailbox and processes, sends, and logs the processed emails." ; For each Mail in the Mailbox ; Format the email with the appropriate informations ; Process the email based on the appropriate rules. ; Send it when it is ready to go. while[not empty? MBX] [ Letter: Mail/Format Make eMail.Obj [ Self/New First MBX ] Print Letter/Header/Subject Mail/Rules Letter Write/Append %Processed.txt First MBX If Send_It [ Write/Append %Sent.txt Mold Letter Letter/Deliver ] Remove MBX ] ] Start: Func [ MBX [File!] ] [ Return Open Load MBX ] ] ====================================================================== -- Sincerely, | Ed Dana | Life's but a knife's edge, anyway. Sooner or later Software Developer | people slip and get cut. 1Ghz Athlon Amiga | -- Larry McMurtry, Streets of Laredo