Conversão de E-mail para HTML

0 respostas
R

Bom Dia,

Estou tentando converter um e-mail de texto para HTML, porém ocorre o seguinte erro:

java.lang.ClassCastException: Unable to cast object of type ‘System.String’ to type ‘java.util.List’. at wfr.com.systems.system_scp.rules.WebrunFunctions.ebfSMTPCreateMessageBody(WebrunFunctions.java:11367) at cli.wfr.com.systems.system_scp.rules.EmailMostrarEmaildebuggy2woo1iqtyuxvqmhmikvww3.run(Unknown Source) at wfr.rules.WFRRule.start(WFRRule.java:761) at wfr.rules.WFRRule.call(WFRRule.java:1823) at wfr.rules.WFRRule.call(WFRRule.java:57) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:167) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:604) at java.lang.Thread.run(Thread.java:883)


Segue script que estou utilizando:

protected final Variant ebfSMTPCreateMessageBody(Variant... variants)
      throws Exception{
    	  
    javax.mail.Multipart messageBody = new javax.mail.internet.MimeMultipart();    
    javax.activation.FileDataSource fds;
    String bodyType;
    String bodyContent;
    javax.mail.internet.MimeBodyPart bodyPart;
    String contentType;
    
    for (int index = 0; index<variants.length; index++){
      	
      bodyType = ((List)variants[index].getObject()).get(0).toString().toLowerCase();
      bodyContent = ((List)variants[index].getObject()).get(1).toString();
      if ((bodyType != null) && (bodyType != "") && (bodyContent != null) && (bodyContent != "")){
        if ((bodyType == "texto") || (bodyType == "html")){
          if (bodyType == "texto"){
            contentType = "text/plain";
          }else{
            contentType = "text/html";
          }
        	
          bodyPart = new javax.mail.internet.MimeBodyPart();
          bodyPart.setContent(bodyContent, contentType);
          messageBody.addBodyPart(bodyPart);
          
        }else if (bodyType == "anexo"){
          fds = new javax.activation.FileDataSource(bodyContent); 
          bodyPart = new javax.mail.internet.MimeBodyPart();
          bodyPart.setDataHandler(new javax.activation.DataHandler(fds));
          bodyPart.setFileName(fds.getName());
          messageBody.addBodyPart(bodyPart);              
        }
      }
    }
    
    return VariantPool.get(messageBody);
  }
Criado 19 de agosto de 2016
Respostas 0
Participantes 1