Exemplo n.º 1
1
        private List<Mail> getMails(string seqPattern, bool isUids = false)
        {
            List<Mail> retVal = new List<Mail>();

            IMAP_Client_FetchHandler fetchHandler = new IMAP_Client_FetchHandler();

            fetchHandler.Rfc822 += new EventHandler<IMAP_Client_Fetch_Rfc822_EArgs>(delegate(object s, IMAP_Client_Fetch_Rfc822_EArgs e)
            {
                MemoryStream storeStream = new MemoryStream();
                e.Stream = storeStream;
                e.StoringCompleted += new EventHandler(delegate(object s1, EventArgs e1)
                {
                    storeStream.Position = 0;
                    Mail_Message mime = Mail_Message.ParseFromStream(storeStream);
                    // TODO: Date check
                    // if (mime.Date < DateTime.Parse("2011-06-20"))
                        retVal.Add(convertToMail(mime));
                });
            });

            IMAP_SequenceSet seqSet = new IMAP_SequenceSet();
            seqSet.Parse(seqPattern);

            _client.Fetch(
                   isUids,
                   seqSet,
                   new IMAP_Fetch_DataItem[]{
                       new IMAP_Fetch_DataItem_Rfc822()
                    },
                   fetchHandler
               );

            return retVal;
        }
Exemplo n.º 2
0
        //GMail Check fcn
        void gmailcheck()
        {
            ip = 1;
            imap = new IMAP_Client();
            fetchHandler = new IMAP_Client_FetchHandler();
            try
            {
                m_pTabPageMail_Messages.Items.Clear();
                imap.Connect("imap.gmail.com", 993, true);
                imap.Login(UserName.Text, Password.Text);
                imap.SelectFolder("INBOX");
                LoadMessages();
                LabelMail.Text = m_pTabPageMail_Messages.Items[ip - 2].SubItems[3].Text + m_pTabPageMail_Messages.Items[ip - 2].SubItems[4].Text;
                mainstring = m_pTabPageMail_Messages.Items[ip - 2].SubItems[3].Text + m_pTabPageMail_Messages.Items[ip - 2].SubItems[4].Text;
                substring = textBoxGmailCheckStr.Text;
                stringresult = mainstring.IndexOf(substring);
                imap.CloseFolder();
                imap.UnsubscribeFolder("INBOX");
                imap.Disconnect();
                imap.Dispose();

                if (stringresult != -1)
                {
                    labelRes.Text = "Found";
                }
                else
                {
                    labelRes.Text = "None";
                }
            }
            catch
            {
                MessageBox.Show("No internet Connection");
            }
        }
Exemplo n.º 3
0
        public void vl2fcn()
        {
            int incr = 0;
            while (true)
            {
                incr = incr + 1;
                Thread.Sleep(int.Parse(textBoxTime.Text) * 1000 * 60);

                    //Page4 Check
                    if (checkBoxWebPage4.Checked == true)
                    {
                        if (incr == int.Parse(textBoxTime2.Text))
                        {
                            Page4checkfcn();
                            Thread.Sleep(10000);
                            //int x = pageSource.IndexOf("Featured Episodes");
                            //newpageSource = pageSource;
                            labelBrowser.Text = newpageSource;
                            int fail = pageSource.IndexOf("download");
                            int fail2 = pageSource.IndexOf("Chrome");

                            if (oldpageSource != newpageSource && fail == -1 && fail2 == -1) // && oldpageSource != null)
                            {
                                oldpageSource = newpageSource;
                                googlecalendarSMSreminder(newpageSource);
                            }
                            incr = 0;
                        }
                    }

                    //Gmail Check
                    if (checkBoxGmail.Checked == true)
                    {
                        //button5_Click(sender, e);
                        ip = 1;
                        imap = new IMAP_Client();
                        fetchHandler = new IMAP_Client_FetchHandler();
                        try
                        {
                            m_pTabPageMail_Messages.Items.Clear();
                            imap.Connect("imap.gmail.com", 993, true);
                            imap.Login(UserName.Text, Password.Text);
                            imap.SelectFolder("INBOX");
                            LoadMessages();
                            LabelMail.Text = m_pTabPageMail_Messages.Items[ip - 2].SubItems[3].Text + m_pTabPageMail_Messages.Items[ip - 2].SubItems[4].Text;
                            mainstring = m_pTabPageMail_Messages.Items[ip - 2].SubItems[3].Text + m_pTabPageMail_Messages.Items[ip - 2].SubItems[4].Text;
                            substring = textBoxGmailCheckStr.Text;
                            stringresult = mainstring.IndexOf(substring);
                            imap.CloseFolder();
                            imap.UnsubscribeFolder("INBOX");
                            imap.Disconnect();
                            imap.Dispose();

                            if (stringresult != -1)
                            {
                                labelRes.Text = "Found";
                            }
                            else
                            {
                                labelRes.Text = "None";
                            }
                        }
                        catch
                        {
                            MessageBox.Show("No internet Connection");
                        }

                        if (mainstring != oldmainstring && stringresult != -1)
                        {
                            googlecalendarSMSreminder(m_pTabPageMail_Messages.Items[ip - 2].SubItems[4].Text);
                            oldmainstring = mainstring;
                        }

                    }

                    //WebPage Check 1,2
                    if (checkBoxWebPage.Checked == true)
                    {
                        //////////////////////////
                        //Check 0 original Lockerz PAGE1

                        // Create a request for the URL.
                        WebRequest request3 = WebRequest.Create(textBoxPage1.Text); //http://ptzplace.lockerz.com/
                        // If required by the server, set the credentials.
                        request3.Credentials = CredentialCache.DefaultCredentials;
                        // Get the response.
                        HttpWebResponse response3 = (HttpWebResponse)request3.GetResponse();
                        // Display the status.
                        Console.WriteLine(response3.StatusDescription);
                        // Get the stream containing content returned by the server.
                        Stream dataStream3 = response3.GetResponseStream();
                        // Open the stream using a StreamReader for easy access.
                        StreamReader reader3 = new StreamReader(dataStream3);
                        // Read the content.
                        string responseFromServer3 = reader3.ReadToEnd();
                        // Save to newer.
                        newer = responseFromServer3;
                        // Cleanup the streams and the response.
                        reader3.Close();
                        dataStream3.Close();
                        response3.Close();

                        //////////////////////////
                        //Check 1 Lockerznews PAGE2

                        // Create a request for the URL.
                        WebRequest request4 = WebRequest.Create(textBoxPage2.Text);
                        // If required by the server, set the credentials.
                        request4.Credentials = CredentialCache.DefaultCredentials;
                        // Get the response.
                        HttpWebResponse response4 = (HttpWebResponse)request4.GetResponse();
                        // Display the status.
                        Console.WriteLine(response4.StatusDescription);
                        // Get the stream containing content returned by the server.
                        Stream dataStream4 = response4.GetResponseStream();
                        // Open the stream using a StreamReader for easy access.
                        StreamReader reader4 = new StreamReader(dataStream4);
                        // Read the content.
                        string responseFromServer4 = reader4.ReadToEnd();
                        // Save to newer.
                        newer1 = responseFromServer4;
                        // Cleanup the streams and the response.
                        reader4.Close();
                        dataStream4.Close();
                        response4.Close();
                        newer1 = newer1.Substring(int.Parse(textBoxStrStart.Text), int.Parse(textBoxStrEnd.Text));

                        // Compare String
                        if (older != newer || older1 != newer1)
                        {
                            googlecalendarSMSreminder("Redemption begins");
                            // Save to older.
                            older = newer;
                            older1 = newer1;

                            labelRedeem.Text = "Reedem started";
                            labelRedeem.ForeColor = Color.Green;

                            //Notify Icon Change
                            notifyIcon1.Icon = SystemIcons.Exclamation;
                            notifyIcon1.BalloonTipTitle = "Lockerz";
                            notifyIcon1.BalloonTipText = "Redemption Start.";
                            notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
                            //this.Click += new EventHandler(Form1_Click);
                            notifyIcon1.ShowBalloonTip(30);
                        }
                    }
                labelLastCheck.Text = DateTime.Now.TimeOfDay.ToString();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets source message with specified ID and stores it to storeStream.
        /// </summary>
        /// <param name="folder">Folder which message to get.</param>
        /// <param name="messageID">ID of message with to get.</param>
        /// <param name="storeStream">Stream where to store message.</param>
        private void GetSourceMessage(string folder,string messageID,Stream storeStream)
        {
            if(m_pSource == null){
                throw new Exception("Source not inited !");
            }

            #region LumiSoft Mail Server User

            // LumiSoft Mail Server User
            if(m_pSourceObject is User){
                User user = (User)m_pSourceObject;
                // Get folder from path                         
                string[] pathParts = folder.Split('/','\\');
                UserFolderCollection currentFolders = user.Folders;
                foreach(string pathPart in pathParts){                                
                    if(!currentFolders.Contains(pathPart)){
                        throw new Exception("Source folder '" + folder + "' doesn't exist !");
                    }
                    else{
                        currentFolders = currentFolders[pathPart].ChildFolders;
                    }
                }
                // Root folder            
                UserFolder sourceFolder = currentFolders.Parent;
                if(sourceFolder == null){                                
                    sourceFolder = m_pUser.Folders[folder];
                }

                sourceFolder.GetMessage(messageID,storeStream);
            }

            #endregion

            #region IMAP

            // IMAP
            else if(m_pSourceObject is IMAP_Client){
                IMAP_Client imap = ((IMAP_Client)m_pSourceObject);

                List<string> retVal = new List<string>();
                IMAP_Client_FetchHandler fetchHandler = new IMAP_Client_FetchHandler();
                fetchHandler.Rfc822 += new EventHandler<IMAP_Client_Fetch_Rfc822_EArgs>(delegate(object s,IMAP_Client_Fetch_Rfc822_EArgs e){ 
                    e.Stream = storeStream;
                    e.StoringCompleted += new EventHandler(delegate(object s1,EventArgs e1){
                    });
                });

                IMAP_SequenceSet seqSet = new IMAP_SequenceSet();
                seqSet.Parse(messageID);
                imap.Fetch(
                    true,
                    seqSet,
                    new IMAP_Fetch_DataItem[]{
                        new IMAP_Fetch_DataItem_Rfc822()
                    },
                    fetchHandler
                );
            }

            #endregion

            #region ZIP

            // ZIP
            else if(m_pSourceObject is ZipFile){
                ZipFile zipFile = (ZipFile)m_pSourceObject;
                foreach(ZipEntry entry in zipFile){
                    if(entry.Name == messageID){
                        SCore.StreamCopy(zipFile.GetInputStream(entry),storeStream);
                        return;
                    }
                }

                throw new Exception("Folder '" + folder + "' message with ID '" + messageID + "', not found !");
            }

            #endregion
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets source messages ID's.
        /// </summary>
        /// <param name="folder">Folder which messages ID's to get.</param>
        /// <returns></returns>
        private string[] GetSourceMessages(string folder)
        {
            if(m_pSource == null){
                throw new Exception("Source not inited !");
            }

            #region LumiSoft Mail Server User

            // LumiSoft Mail Server User
            if(m_pSourceObject is User){
                User user = (User)m_pSourceObject;
                // Get folder from path                         
                string[] pathParts = folder.Split('/','\\');
                UserFolderCollection currentFolders = user.Folders;
                foreach(string pathPart in pathParts){                                
                    if(!currentFolders.Contains(pathPart)){
                        throw new Exception("Source folder '" + folder + "' doesn't exist !");
                    }
                    else{
                        currentFolders = currentFolders[pathPart].ChildFolders;
                    }
                }
                // Root folder            
                UserFolder sourceFolder = currentFolders.Parent;
                if(sourceFolder == null){                                
                    sourceFolder = m_pUser.Folders[folder];
                }

                List<string> retVal = new List<string>();
                DataSet ds = sourceFolder.GetMessagesInfo();
                if(ds.Tables.Contains("MessagesInfo")){
                    foreach(DataRow dr in ds.Tables["MessagesInfo"].Rows){
                        retVal.Add(dr["ID"].ToString());
                    }
                }
                return retVal.ToArray();
            }

            #endregion

            #region IMAP

            // IMAP
            else if(m_pSourceObject is IMAP_Client){
                IMAP_Client imap = ((IMAP_Client)m_pSourceObject);
                imap.SelectFolder(folder);

                List<string> retVal = new List<string>();
                IMAP_Client_FetchHandler fetchHandler = new IMAP_Client_FetchHandler();
                fetchHandler.UID += new EventHandler<EventArgs<long>>(delegate(object s,EventArgs<long> e){
                    retVal.Add(e.Value.ToString());
                });

                IMAP_SequenceSet seqSet = new IMAP_SequenceSet();
                seqSet.Parse("1:*");
                imap.Fetch(
                    false,
                    seqSet,
                    new IMAP_Fetch_DataItem[]{
                        new IMAP_Fetch_DataItem_Uid()
                    },
                    fetchHandler
                );

                return retVal.ToArray();
            }

            #endregion

            #region ZIP

            // ZIP
            else if(m_pSourceObject is ZipFile){
                ZipFile zipFile = (ZipFile)m_pSourceObject;
                List<string> retVal = new List<string>();
                foreach(ZipEntry entry in zipFile){
                    if(Path.GetDirectoryName(entry.Name).Replace("\\","/").ToLower() == folder.Replace("\\","/").ToLower() && entry.Name.EndsWith(".eml")){
                        retVal.Add(entry.Name);
                    }
                }
                return retVal.ToArray();
            }

            #endregion

            throw new Exception("Invalid source, never should reach here !");
        }
Exemplo n.º 6
-1
        public void getEmail(string login, string password)
        {
            IMAP_Client client = new IMAP_Client();
            client.Connect("imap.yandex.ru", 993, true);
            client.Login(login, password);
            client.SelectFolder("INBOX");

            IMAP_SequenceSet sequence = new IMAP_SequenceSet();
            //sequence.Parse("*:1"); // from first to last
            IMAP_Client_FetchHandler fetchHandler = new IMAP_Client_FetchHandler();

            fetchHandler.NextMessage += new EventHandler(delegate(object s, EventArgs e)
            {
                Console.WriteLine("next message");
            });

            fetchHandler.Envelope += new EventHandler<EventArgs<IMAP_Envelope>>(delegate(object s, EventArgs<IMAP_Envelope> e)
            {
                IMAP_Envelope envelope = e.Value;
                if (envelope.From != null && !String.IsNullOrWhiteSpace(envelope.Subject))
                {
                    Console.WriteLine(envelope.Subject);
                }
            });
            // the best way to find unread emails is to perform server search
            int[] unseen_ids = client.Search(false, "UTF-8", "unseen");
            Console.WriteLine("unseen count: " + unseen_ids.Count().ToString());
            // now we need to initiate our sequence of messages to be fetched
            sequence.Parse(string.Join(",", unseen_ids));
            // fetch messages now
            client.Fetch(false, sequence, new IMAP_Fetch_DataItem[] { new IMAP_Fetch_DataItem_Envelope() }, fetchHandler);
            // uncomment this line to mark messages as read
            // client.StoreMessageFlags(false, sequence, IMAP_Flags_SetType.Add, IMAP_MessageFlags.Seen);
        }