You are missing imports for MimeUtility and UnsupportedEncodingException.