如何使用Java邮件机器人同步应用程序的电子邮件服务器的电子邮件 [英] how to synchronize application email to server email using java mail in android

查看:442
本文介绍了如何使用Java邮件机器人同步应用程序的电子邮件服务器的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要同步更改更改电子邮件应用程序,然后自动改变服务器的电子邮件。例如: - 我已阅读电子邮件应用程序中的未读消息,则服务器自动电子邮件更改未读的邮件阅读邮件

我的电子邮件应用程序使用邮件jar文件,activati​​on.jar,然后额外的jar文件的使用  并按照code是用于连接电子邮件应用程序服务器的电子邮件。

 属性道具= System.getProperties();
            props.setProperty(mail.store.protocol,IMAPS);
            props.put(mail.smtp.starttls.enable,真);
            身份验证身份验证=新的Authenticator(){
                受保护的PasswordAut​​hentication的getPasswordAut​​hentication(){
                    返回新的PasswordAut​​hentication(USEREMAILID,密码);
                    }
            };
            sessioned =作为Session.getDefaultInstance(道具,AUTH);
            店内= sessioned.getStore(IMAPS);
           store.connect(smtp.gmail.com,USEREMAILID,密码);
             收件箱= store.getFolder(收件箱);
            inbox.open(Folder.READ_ONLY);
            FlagTerm英尺=新FlagTerm(新标志(Flags.Flag.SEEN),FALSE);
            UNReadmessages = inbox.search(英尺);
 

解决方案

我已经解决了这个问题。
千万不要关闭在运行时的连接,低于code。

  inbox.open(Folder.READ_WRITE);
 

i want to change synchronously change in email application then automatic change in server email. For example :- i have read the unread message on email application then automatic server email change unread mail to read mail.

my email application has use mail jar file, activation.jar and additional jar file use and following code are use for connectivity email application to server email..

Properties props = System.getProperties();
            props.setProperty("mail.store.protocol", "imaps");
            props.put("mail.smtp.starttls.enable","true");
            Authenticator auth = new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication(){
                    return new PasswordAuthentication("USEREMAILID","PASSWORD ");
                    }
            };
            sessioned= Session.getDefaultInstance(props, auth);
            store = sessioned.getStore("imaps");
           store.connect("smtp.gmail.com","USEREMAILID","PASSWORD ");
             inbox = store.getFolder("inbox");
            inbox.open(Folder.READ_ONLY);
            FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
            UNReadmessages = inbox.search(ft);

解决方案

I have solved the issue.
Never close the connection on run time, with below code.

   inbox.open(Folder.READ_WRITE);

这篇关于如何使用Java邮件机器人同步应用程序的电子邮件服务器的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆