Package com.im.imjutil.email

Examples of com.im.imjutil.email.Email


   
    Thread thread = new Thread() {
      @Override
      public void run() {
        try {
          Email email = new Email();
          // Cria a mensagem
          email.setSubject(Convert.toString(
              "[ATENCAO] Ocorreu um erro no sistema: ",
              Configurator.getProperty("system.name")
          ));
         
          String machine;
          try {
             NetworkInterface ni = NetworkInterface.getByName("eth0");
             machine = ni.toString().replaceAll("\\n", " ");
          } catch (Exception e) {
             machine = "DESCONHECIDA";
          }
         
          email.setMessage(Convert.toString(
              "<h2>ATENCAO: Ocorreu um erro no sistema!</h2>",
              "* Maquina: ", machine, "<br>",
              "* Produto: ",
              Configurator.getProperty("system.name"), "<br>",
              "* Versao: ",
              Configurator.getProperty("system.version"), "<br>",
              "* Mensagem: ", message, "<br>",
              "* Codigo de erro: ", code, "<br>",
              "* Erro: ", error.getClass().getSimpleName(),
              " -- ", error.getMessage(),
              (
                error.getCause() != null ? Convert.toString(
                " -- | -- Caused by: ",
                error.getCause().getClass().getSimpleName(),
                " -- ", error.getCause().getMessage()) : ""
                ),
              "<br>",
              "* Stacktrace: em anexo"
          ));

          // Configura os envolvidos a receber a notificao.
          String to = Configurator.getProperty("system.email");
          email.setTo(Arrays.asList(to.split("\\s*[,;]\\s*")));

          // Cria o arquivo com o stacktrace do erro e anexa ao email
          File fileError = File.createTempFile(Convert.toString(
              "errocode_", code, "---"), ".txt");
          PrintWriter print = new PrintWriter(fileError);
          error.printStackTrace(print);
          print.close();
          email.addAttachment(fileError);
         
          // Envia o email para os destinatarios configurados.
          EmailSender.send(email);
       
        } catch (Exception e) {
View Full Code Here


   * @param config A configuracao do sender do email
   * @param emails Um ou mais emails a serem enviados
   */
  public static void sendEmail(Properties config, String subject,
      String message, String... to) {
    Email email = new Email(to);
    email.setSubject(subject);
    email.setMessage(message);
    sendEmail(config, email);
  }
View Full Code Here

TOP

Related Classes of com.im.imjutil.email.Email

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.