CS2910
Lab 7

This is an old version of this course, from Fall 2015. A newer version is available here.

Lab assignment

This is a team assignment; each team should be two members unless a different size is approved by the instructor.

Introduction

The goal of this lab is to write (actually, modify) a short Python program, to parse an email message received via IMAP, using the Python email module. The resulting program will read the raw text of an email from a file, and store each part, properly decoded, in a separate file.

Procedure

  1. Download the skeleton Python template: parse_email.py
  2. Edit the header of the file to include your team members' names, in the format provided.
  3. Complete the process_part method decode at least the following content types:

    • base64
    • quoted-printable (Hint: look at the import statements at the top of the code. Hint2: Quoted-printable is usually used for text containing a few accented characters.)

    Unknown content types should not be processed (return the same text), though if that does not produce the right result, you might investigate decoding options.

  4. Test your resulting program on various emails, fetched with the code from The IMAP code from class, or something similar. Make sure you get come more complex ones, like:
    • Attachments of various types
    • "Reply" messages with the original message included at the bottom. (Or with a message "attached" to the original message.)
    • Combinations of various parts (e.g., forwarded message that had an attachment) You will likely have to add the proper file type (extension) to the file names in order to open each part with an appropriate application.
  5. Add comments at the end of your Python file, with the following information:
    • What you learned about the structure of email messages, parts, and decoding.
    • A description of the functionality you implemented and the results of your testing.
    • Comments on your experience in completing the lab, including any problems you encountered. Briefly explain what you learned.
    • Questions and suggestions.

Additional implementation details will be discussed in class. If you have questions about these requirements, ask in class or lab.

If this base functionality turns out to be too easy, you may experiment with adding additional functions, but be sure the basic requirements are still met. Make sure you always have a working backup copy before adding features.

Try to divide up the primary responsibility for parts of the program in an equitable way.

Submission

Please submit your file below. Please make sure your usernames are separated by hyphens and in alphabetical order.

(Acknowledgements: The original version of this lab written by Dr. Sebern.)

Submission Instructions for Dr. Yoder

Submission (Week 9, Monday, 11pm)

Submit your lab electronically before the deadline listed above.

You should submit your solution only once, so be sure you are happy with your solution before you submit it.