MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.6k stars 623 forks source link

How can I use 'appendMessageOperation' #1865

Closed bonitahlee closed 4 years ago

bonitahlee commented 4 years ago

I'm struggling with 'importing other mail' to IMAP server.

It always returns fail when I start IMAPAppendMessageOperation. Please give me the solution. Thank you in advance :)

Here is my code.

    IMAPSession imap = new IMAPSession();
    imap.setUsername(email);
    imap.setPassword(password);
    imap.setHostname(imap_hostname);
    imap.setPort(imap_port);
    imap.setConnectionType(connection_type);

    byte[] contents = "have a nice day".getBytes();
    IMAPAppendMessageOperation operation = imap.appendMessageOperation("INBOX", contents, 0);
    operation.start(new OperationCallback() {
        @Override
        public void succeeded() {
            Log.e(TAG, "success");
        }

        @Override
        public void failed(MailException e) {
            Log.e(TAG, "fail");
        }
    });
bonitahlee commented 4 years ago

I found out how to use that method. I had to get bytes array from message using BufferedInputStream.

appendMessageOperation("INBOX", byte array, 0)