
# for each student in the class e-mail list, sends the cmulative quiz
# records for that student; the list lines may either all have the
# @ucdavis.edu suffix or none have it

mailquizrecs <- function(emaillist="EMailList",hasucdsuffix=TRUE) {
   # this reads in the file, placing the contents into an R list, one
   # list element per line of the file
   addrs <- scan(emaillist,what="",sep="\n")
   for (addr in addrs) {
      if (!hasucdsuffix) {
         # add suffix
         fulladdr <- paste(addr,"@ucdavis.edu",sep="")
      } else {
         fulladdr <- addr
         # find the base e-mail address, since the Registrar's files
         # show only that
         tmp <- strsplit(addr,"@")
         addr <- tmp[[1]][1]
      }
      # mutt is a command-line e-mail utility; the -s option specifies a
      # Subject title for the mail
      muttcmd <- paste("mutt -s 'cumul quiz recs'",fulladdr)
      cmd <- paste("grep",addr,"Q*/Q* |",muttcmd) 
      print(cmd)
      # emit a command to the shell
      system(cmd)
   }
}
