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 625 forks source link

Android:POPSession get the email data content garbled, subject is empty #1422

Open thingLi opened 8 years ago

thingLi commented 8 years ago

The log is as follows: [ EmailInboxBean{fromName='lt227899938@139.com', subject='我正在试用mailCore2发送邮件,这是主题!', content='我是邮件回复的内容', time='16/04/29'}, EmailInboxBean{fromName='EasyBug', subject='获取密码', content='您好,以下是您的账号信息', time='16/01/04'}, EmailInboxBean{fromName='95555@message.cmbchina.com', subject='', content='Ç×°®µÄÓû§: ¸ÐлʹÓÃÒ»ÍøͨÓû§£¬Äú±¾´Î²Ù×÷µÄ¼¤»îÂëÊÇ 088189 ¡£ (ÕâÊÇÒ»·âÓÉÕÐÉÌÒøÐÐ×Ô¶¯·¢Ë͵ÄEmail£¬ÄúÎÞÐè»Ø¸´¡£)', time='15/02/08'}, EmailInboxBean{fromName='95555@message.cmbchina.com', subject='', content='»¶Ó­¿ªÁ¢ÕÐÉÌÒøÐÐÕË»§£¡ÄúÔ¤ÁôÔÚÎÒÐеÄ180****0447ÊÖ»úºÅ·Ç³£ÖØÒª£¬ÊÇÎÒÐÐÓëÄúÁªÏµºÍ½»Ò×È·ÈϵĹؼüµç»°£¬ÈçÐè±ä¸üÇ뼰ʱͨ¹ýÎÒÐÐרҵ°æ»ò¹ñ̨Ð޸ġ£Óÿ¨Ö¸ÄÏÏê¼ûhttp://e95555.cn/vrn7nR', time='15/02/08'}]

This is part of my code.

     //获取邮件信息
     final POPFetchMessagesOperation popFetchMessagesOperation =                                             session.fetchMessagesOperation();
    popFetchMessagesOperation.start(new OperationCallback() {
           @Override
           public void succeeded() {
       //获取收件箱数据
        List info = popFetchMessagesOperation.messages();
        Collections.sort(info,new IndexComparetor());
        for (int i = 0; i < 10; i++) {
            final POPMessageInfo popMessageInfo = info.get(i);

            //获取头信息
            final POPFetchHeaderOperation operation = session.fetchHeaderOperation(popMessageInfo.index());
            MyLog.d("email","popMessageInfo.index= "+popMessageInfo.index());
            final int finalI = i;
            operation.start(new OperationCallback() {
                @Override
                public void succeeded() {

                    MessageHeader messageHeader = operation.header();

                    //发件人 
                    String sendFrom = messageHeader.from().mailbox();
                    String displayName = messageHeader.from().displayName();//别名

                    // 接收时间
                    Date getTime = messageHeader.receivedDate();

                    //主题
                    String subject = messageHeader.subject();

                    //邮箱内容
                    final POPFetchMessageOperation popFetchMessageOperation = session.fetchMessageOperation(popMessageInfo.index());
                    popFetchMessageOperation.start(new OperationCallback() {
                        @Override
                        public void succeeded() {
                            byte[] bytes = popFetchMessageOperation.data();

                            MessageParser parser = MessageParser.messageParserWithData(bytes);
                            String body = parser.plainTextBodyRendering(true);
                        }

                        @Override
                        public void failed(MailException e) {
                            MyLog.e("email", "获取邮箱内容 e=" + e.getMessage() + "/");
                        }
                    });
                }

                @Override
                public void failed(MailException e) {
                    MyLog.e("email", "获取头信息 e=" + e.getMessage() + "/");
                }
            });
        }
    }

    @Override
    public void failed(MailException e) {
        MyLog.e("email", "获取收件箱信息e=" + e.getMessage() + "/");
    }
});

How to resolve? Garbled and subject null thank you!

dinhvh commented 8 years ago

Coud you provide RFC 822 source of the messagE?

thingLi commented 8 years ago

I don't know what you want me to offer, I was using AndroidStudio development, integration, I tried to generate arr documents as required, but not successful.

Build for Android $ export ANDROID_SDK=/path/to/android-sdk $ export ANDROID_NDK=/path/to/android-ndk $ cd build-android $ ./build.sh It will produce the following binaries: mailcore2-android-version.aar

So, my arr file is downloaded from here: http://d.etpan.org/mailcore2-deps/mailcore2-android-beta/mailcore2-android-3-beta-3.aar

dinhvh commented 8 years ago

What's the content of the message? Could you put them in a file and send those?

dinhvh commented 8 years ago

Also, see https://en.wikipedia.org/wiki/RFC_822

tracy891110 commented 8 years ago

你好, 你是不是Android端运用这个mailCore框架,我现在也准备用这个,但是遇到了问题,能指导一下么

yq1 commented 7 years ago

如何解决获取subject为空的问题。谢谢!

zhangyunpenggithub commented 6 years ago

@thingLi I met the same problem. How did you fix it ?

zhangyunpenggithub commented 6 years ago

@yq1 你解决了subject为空的问题了吗

yq1 commented 6 years ago

当时直接取值没有取到。做了个替代方案,从其父类获取,然后复制给子对象。这样做会导致刷新速度慢。

在 2018-01-23 16:57:42,"zhangyunpenggithub" notifications@github.com 写道:

@yq1 你解决了subject为空的问题了吗

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

zhangyunpenggithub commented 6 years ago

@yq1 能具体说一下吗,你用的是哪个父类?

yq1 commented 6 years ago

获取subject的对象的for 循环的外面的对象。具体的记不起来了。你用日志打印看下

发自我的 iPhone

在 2018年1月24日,09:41,zhangyunpenggithub notifications@github.com 写道:

@yq1 能具体说一下吗,你用的是哪个父类?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

joiman commented 6 years ago

subject为空,应该是ICU加载不到数据导致解码失败。我们通过以下方法解决了: 在http://apps.icu-project.org/datacustom/ 下载dat文件(icudt54l.dat),放入apk,启动后拷贝到固定目录icudatadir,初始化coremail时,MCString有个setICUDataDirectory,设置为icudatadir,记得带上最后的‘/'

gnmmdk commented 1 year ago

如下的链接解决了。但是这位大哥他自己编译的aar包,有修改源码。 https://github.com/kongpf8848/MailCore2Example