示例#1
0
        private void button5_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Warning this is a very time intensive function ( 5 - 10 minutes )");
            Gmail myGmail = new Gmail();

            int iNumEmails = 0;

            Program.Folders.Clear();

            for (int j = 0; j < Program.EmailAccounts.Count; j++)
            {
                ImapClient ic = new ImapClient("imap.gmail.com", Program.EmailAccounts[j].Login, Program.EmailAccounts[j].Password, ImapClient.AuthMethods.Login, 993, true);

                Mailbox[] ma = ic.ListMailboxes("", "*");

                foreach (Mailbox ms in ma)
                {
                    if (ms.Name.StartsWith("[Gmail]"))
                    {
                        continue;
                    }

                    Folder TempObject2 = new Folder();

                    TempObject2.FolderName = ms.Name;

                    Program.Folders.Add(TempObject2);
                }

                Folder TempObject3 = new Folder();

                TempObject3.FolderName = "[Gmail]/Spam";

                Program.Folders.Add(TempObject3);

                for (int i = 0; i < Program.Folders.Count; i++)
                {
                    string sFolder = Program.Folders[i].FolderName;

                    iNumEmails = ic.GetMessageCount(sFolder);

                    if (iNumEmails == 0)
                    {
                        continue;
                    }

                    ChangeCurrentFolderLabel(sFolder);

                    ic.SelectMailbox(sFolder);

                    try
                    {
                        ic.DeleteMessage(1);
                    }
                    catch
                    {
                    }
                }
            }
            MessageBox.Show("All Done cleaning Emails");
        }
示例#2
0
        private void StartScan()
        {
            Gmail myGmail = new Gmail();

            string buffer = "";

            int iNumEmails = 0;

            Program.Folders.Clear();

            for (int j = 0; j < Program.EmailAccounts.Count; j++)
            {
                ImapClient ic = new ImapClient("imap.gmail.com", Program.EmailAccounts[j].Login, Program.EmailAccounts[j].Password, ImapClient.AuthMethods.Login, 993, true);

                Mailbox[] ma = ic.ListMailboxes("", "*");

                foreach (Mailbox ms in ma)
                {
                    if (ms.Name.StartsWith("[Gmail]"))
                    {
                        continue;
                    }

                    Folder TempObject2 = new Folder();

                    TempObject2.FolderName = ms.Name;

                    Program.Folders.Add(TempObject2);
                }

                Folder TempObject3 = new Folder();

                TempObject3.FolderName = "[Gmail]/Spam";

                Program.Folders.Add(TempObject3);

                for (int i = 0; i < Program.Folders.Count; i++)
                {
                    string sFolder = Program.Folders[i].FolderName;

                    iNumEmails = ic.GetMessageCount(sFolder);

                    if (iNumEmails == 0)
                    {
                        continue;
                    }

                    ChangeCurrentFolderLabel(sFolder);

                    ic.SelectMailbox(sFolder);

                    for (int k = 1; k < iNumEmails; k++)
                    {
                        if (Pause)
                        {
                            evt.WaitOne();
                        }

                        ChangeCurLabel((k + 1).ToString());
                        ChangeMaxLabel(iNumEmails.ToString());

                        MailMessage m = null;

                        myGmail.iEmail = k;
                        try
                        {
                            m = ic.GetMessage(k, false, true);

                            if ((buffer = myGmail.CheckEmails(sFolder, m.Body)) != "None")
                            {
                                ParseWildcardOption(myGmail.CurWildcardOption, buffer);

                                evt.WaitOne();
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }