示例#1
0
     def sendmail(self, name, receiver):
          # Open a plain text file for reading. For this example, assume that
          # the text file contains only ASCII characters
          message = Message(self.sender, receiver, self.labnum)
          message.addCannedText(os.path.join(self.curDir, self.text), self.labnum)

          # get the files
          codeFile  = name + CODE_S
          gradeFile = name + GRADE_S
          codePath  = os.path.join(self.curDir, codeFile)
          gradePath = os.path.join(self.curDir, gradeFile)

          # check for errors
          if not os.path.isfile(codePath):
               raise BadPathException(codePath)
          if not os.path.isfile(gradePath):
               raise BadPathException(gradePath)

          # add the attachments
          # attach the .txt rubric
          message.attachRubric(gradePath, gradeFile)
          message.attachCommentedCode(codePath, codeFile)

          # send the message
          self.server.sendmail(self.sender, [receiver], message.toString())