English 中文(简体)
为什么与Gmail服务器的连接将我的邮件状况从“准备”改为“再使用”?
原标题:Why the connection to Gmail server is change my mails situation from "Unread" to "Read"?

我可以从电子邮件服务器收到我的邮件,并在我的安康项目一览表上展示主题。 昨天,我开始改变我的邮件形象,以了解“不阅读”或“阅读”的情况。 但是,当时我认识到,当我申请与Gmail服务器连接并收受我的邮件时,该信使邮件成为SEEN的邮件。 由于这一原因,我可以把我的形象描绘成不阅读的邮件。

我指的是,我从电子邮件服务器收到我的邮件,而不用改变电子邮件服务器上的情况。 我想收到3份没有读写,4份是服务器。

我应该做些什么?

我的联系守则样本是:

public Message[] ConnectionToServer(String email, String password)
            throws Exception 
        {
        Properties props = System.getProperties();
        props.setProperty("mail.imaps.partialfetch", "false");
        URLName server = new URLName("imaps://" + email + ":" + password + "@imap.gmail.com/INBOX");
        Session session = Session.getDefaultInstance(props, null);
        folder = session.getFolder(server);

        if (folder == null) 
        {
            System.exit(0);
        }
        folder.open(Folder.READ_WRITE);     
        messages = folder.getMessages();

        for (int i = messages.length - 1; i >= 23; i--) 
        {
            Part p = messages[i]; 

            subject = messages[i].getSubject();

                     if (messages[i].isSet(Flags.Flag.RECENT)) {
            isSet = true;
            System.out.println("Recent");
            isSetlist.add(String.valueOf(isSet));
        }
        if (messages[i].isSet(Flags.Flag.SEEN)) 
        {
            isSet = false;
            System.out.println("Read");
            isSetlist.add(String.valueOf(isSet));
        }
        else
        {
            isSet = true;
            System.out.println("Recent");
            isSetlist.add(String.valueOf(isSet));
        }

                        body = getText(p);

            list.add(body);
        }
        return (Message[]) messages;
    }

I am using getContent in getText() method

public String getText(Part p) throws MessagingException, IOException {

        if (p.isMimeType("text/*")) {
            boolean textIsHtml = false;
            String s = (String) p.getContent();

            textIsHtml = p.isMimeType("text/html");
            return String.valueOf(s);
        }

        if (p.isMimeType("multipart/alternative")) {
            // prefer html text over plain text
            Multipart mp = (Multipart) p.getContent();
            String text = null;
            for (int i = 0; i < mp.getCount(); i++) {
                Part bp = mp.getBodyPart(i);
                if (bp.isMimeType("text/plain")) {
                    if (text == null)
                        text = getText(bp);
                    continue;
                } else if (bp.isMimeType("text/html")) {
                    String s = getText(bp);
                    if (s != null)
                        return String.valueOf(s);
                } else {
                    return getText(bp);
                }
            }
            return text;
        } else if (p.isMimeType("multipart/*")) {
            Multipart mp = (Multipart) p.getContent();
            for (int i = 0; i < mp.getCount(); i++) {
                String s = getText(mp.getBodyPart(i));
                if (s != null)
                    return String.valueOf(s);
            }
        }

        return null;
    }
最佳回答

获取信息旗帜(确定电文是否为SEEN),然后才能查阅内容。 查阅内容通常为SEEN国旗。

问题回答

如果您不需要做任何修改,则在ReADONLY模式中打开文件夹――轮流尝试保留Messageflags/getContent 。





相关问题
how does gmail detect mouse movement?

if you are inactive on gmail, by not moving your mouse for a while, it changes your chat status to orange which means idle. but when you start moving the mouse again it turns it back to green meaning ...

reading mails using python

how do i read mails from my mail box using python?? import getpass, imaplib M = imaplib.IMAP4( IMAP4.gmail.com:993 ) M.login(getpass.getuser(), getpass.getpass()) M.select() typ, data = M.search(None,...

SMTP Service not available

I am trying to create a web application which upon entering your email address and message , sends an email with this information from the email address. I used this: try { ...

How to auto log into gmail atom feed with Python?

Gmail has this sweet thing going on to get an atom feed: def gmail_url(user, pwd): return "https://"+str(user)+":"+str(pwd)+"@gmail.google.com/gmail/feed/atom" Now when you do this in a browser, ...

Can I build an addin for Gmail?

Is there a way I can create an addin for my Gmail account? Is GreaseMonkey the only real way? I use Gmail for customer service, and I d like to create a tool that looks up the customer and preps a ...

Web Link in a mail is not rendering as link in yahoo

string from = "abc@gmail.com"; string to = "xyz@gmail.com,xyz@yahoo.co.in"; string password="abcxyz"; MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(to); mail.From = new ...

热门标签