Faria,
Acabei de ver seu código, está diferente do meu.
Essa variavel: "multipart/mixed;boundary=--AaZz" --AaZZ eu que criei, você pode utilizar qualquer coisa... tipo ---TextoXml bla.. mais tranquilo.
Outro ponto, você não precisa utilizar toda vez --AaZz (separador do Content-Type do Content-Disposition), no seu código para quase tudo você colocou isso, não sei se vai funcionar direito.
String output = new String(""); //output = "--AaZz" + CRLF + "Content-Type: text/plain; charset=UTF-8" + CRLF + "Content-Disposition: inline" + CRLF + CRLF + body + CRLF + "----AaZz" + CRLF + "Content_Type: application/xml; name=" + filename + CRLF + "Content-Disposition: attachment; filename=" + filename + CRLF + CRLF + attachment + CRLF; //output = "--AaZz" + CRLF + "Content-Type: text/plain; charset=us-ascii" + CRLF + body + CRLF + "--AaZz" + CRLF + "Content_Type: application/xml; name=" + filename + CRLF + "Content-Disposition: attachment; filename=" + filename + CRLF + attachment + CRLF + "--AaZz"; //First part output = "--" + "--AaZz" + CRLF + "Content-Type: text/plain; charset=UTF-8" + CRLF + "Content-Transfer-Encoding: 8bit" + CRLF + "Content-Disposition: inline" + CRLF + body + CRLF //Second part + "--" + "--AaZz" + CRLF + "Content-Type: Application/xml; name=" +filename + CRLF + "Content-Transfer-Encoding: 8bit" + CRLF //+ "Content-Transfer-Encoding: base64" + CRLF + "Content-Disposition: attachment; filename=" + filename + CRLF + CRLF + attachment;
Meu código:
public String getnfeText() { // Corpo de texto da NF-e autorizada nfeText ="Prezado cliente, "+getGap()+getGap()+ "Segue arquivo anexo referente a Nota Fiscal Eletrônica "+ getGap()+ getGap()+ "Número da NF-e Autorizada: "+ numeroNFe + getGap()+ "Série: "+ serieNFe+ getGap()+ "Data emissão (MM/AAAA): " + dataNFe + getGap()+getGap()+ "Atenciosamente,"+getGap()+getGap()+ "EMPRESA X"; // Preencher o campo Content com o corpo de texto e arquivo .XML em anexo. content = "----AaZz\r\n Content-Type: text/plain; charset=UTF-8\r\n" + "Content-Disposition: inline\r\n\r\n" + nfeText + "\r\n----AaZz\r\nContent-Disposition: attachment; filename="+ "NF-e EMPRESA X - " + chaveNFe + ".xml" +"\r\n\r\n" + xmlString + "\r\n"; return content; }
nfeText - variavel tipo String , que recebe o corpo de texto.
content - variavel do tipo Element, repare que eu utilizo em dois momentos o separador ----AaZz - na hora de separar o texto (text/plain - formato UTF-8) do anexo attachment;filename.
Outro ponto que não tenho certeza, mais pode está ocorrendo uma "zica" é na hora dessa conversão:
//XML DA NF-e String conteudo_xml = new String(""); conteudo_xml = (inptxml.replaceAll("<nm:", "<").replaceAll("</nm:", "</").replaceAll(System.getProperty("line.separator"), "").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "").replaceAll("\n\r", "").replaceAll("\n\t", "").replaceAll("\r\t", "").replaceAll("\r\n", "").replaceAll("\t\n", "").replaceAll("\t\r", "").replaceAll("\r\r", "").replaceAll("\n\n", "").replaceAll("\t\t", ""));
Não precisei fazer isso.
Mais você está no caminho velho, teste ai e poste o resultado !!
Abraçs,
Ricardo Viana.