Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

14.4 | Processing a Eudora Mailbox

The following code fragment shows the control structure required to process a Eudora mailbox into individual e-mail messages. The processing of each message has been delegated to the ProcessMessage function. This function is used by both the Linux and Eudora converters. Note how the sentinel string "From ???@???" is used to chop the contents of the mailbox into individual messages.

CD-ROM reference=14005.txt
def DoEudoraMailbox(f):
      # f is a file object.
      # Chop the contents of a Eudora mailbox
      # into individual messages for processing
      # by the ProcessMessage subroutine.
      Message = []
      L = f.readline()
      while L:
            if string.find(L,"From ???@???")!=-1:
                  -# Full message accumulated in the Message  # list, so process it to XML.
                  ProcessMessage(Message,out)
                  Message = []
            else:
                  # Accumulate e-mail contents line by line in
                  # Message list.
                  Message.append (L)
            L = f.readline()
      if Message:
            # Last message in the mailbox
            ProcessMessage(Message,out)
  • + Share This
  • 🔖 Save To Your Account