Search in sources :

Example 6 with BinaryTempFileBody

use of com.fsck.k9.mail.internet.BinaryTempFileBody in project k-9 by k9mail.

the class MessageTest method binaryBodyPart.

private MimeBodyPart binaryBodyPart() throws IOException, MessagingException {
    String encodedTestString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz0123456789+/\r\n";
    BinaryTempFileBody tempFileBody = new BinaryTempFileBody(MimeUtil.ENC_BASE64);
    InputStream in = new ByteArrayInputStream(encodedTestString.getBytes("UTF-8"));
    OutputStream out = tempFileBody.getOutputStream();
    try {
        IOUtils.copy(in, out);
    } finally {
        out.close();
    }
    MimeBodyPart bodyPart = new MimeBodyPart(tempFileBody, "application/octet-stream");
    bodyPart.setEncoding(MimeUtil.ENC_BASE64);
    return bodyPart;
}
Also used : BinaryTempFileBody(com.fsck.k9.mail.internet.BinaryTempFileBody) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart)

Aggregations

BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)6 OutputStream (java.io.OutputStream)6 PendingIntent (android.app.PendingIntent)4 Intent (android.content.Intent)4 OpenPgpDataSource (org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ComposeCryptoStatus (com.fsck.k9.activity.compose.ComposeCryptoStatus)2 MessagingException (com.fsck.k9.mail.MessagingException)2 EOLConvertingOutputStream (com.fsck.k9.mail.filter.EOLConvertingOutputStream)2 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)2 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)2 Callback (com.fsck.k9.message.MessageBuilder.Callback)2 Recipient (com.fsck.k9.view.RecipientSelectView.Recipient)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 OpenPgpError (org.openintents.openpgp.OpenPgpError)2 BodyPart (com.fsck.k9.mail.BodyPart)1 BinaryTempFileMessageBody (com.fsck.k9.mail.internet.BinaryTempFileMessageBody)1 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1