Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How send e-mail with XML + PDF and body text

Hi everyone,

I have a new requirement but I´m with doubts, how to send an e-mail with two attachements (XML and PDF) and body text using -

MIME: multipart/mixed;boundary

I already have code to send XML + body text as you can see below:

Element contentType = docout.createElement("Content_Type");

  root.appendChild(contentType);

  Text contentTypeText = docout.createTextNode("multipart/mixed;boundary=--AaZz");

  absTraceLog.addDebugMessage("Content_Type e-mail --- "+contentTypeText.toString());

  contentType.appendChild(contentTypeText)

String text = "----AaZz\r\nContent-Type: text/plain; charset=UTF-8\r\n" +

        "Content-Disposition: inline\r\n\r\n" + nfeText +

        "\r\n----AaZz\r\nContent-Disposition: attachment; filename="+ prefixo +" "+ chaveNFe +".xml" +"\r\n\r\n" + xmlString + "\r\n";

Element content = docout.createElement("Content");

root.appendChild(content);

contentText = docout.createTextNode(text);

Content.appendChild(contentText);

The code above work good, but I can´t duplicate any field from XiMail 3.0 - because it´s 0:1.

So how to do that ?

Thanks.

Regards,

BR.

Viana.

Former Member
Former Member replied

Eng,

That´s works good with mailPackage:

            content= "--" + "--Zz" + CRLF

                    + "Content-Type: text/html; charset=UTF-8" + CRLF

                    + "Content-Disposition: inline" + CRLF + CRLF

                    + textBodyMail + CRLF

                    + "--" + "--Zz" + CRLF

                    + "Content-Type: application/xml; name=" + attachmentName + CRLF

                    + "Content-Disposition: attachment; filename=" + attachmentName + CRLF

                    + "Content-Transfer-Encoding: base64" + CRLF + CRLF

                    + encoder.encode(inputString.getBytes("UTF-8")) + CRLF

                    + "--" + "--Zz" + CRLF

                    + "Content-Type: application/pdf; name=" + pdfName + CRLF

                    + "Content-Disposition: attachment; filename=" + pdfName + CRLF

                    + "Content-Transfer-Encoding: base64" + CRLF + CRLF

                    + encoder.encodeBuffer(new BASE64Decoder().decodeBuffer(pdfAttachment));

Regards,

BR.

Ricardo Viana.

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question