Connect() публичный Метод

Connects to IMAP server.
public Connect ( string host, int port ) : void
host string Host name.
port int Port number.
Результат void
Пример #1
0
        public ActionResult About()
        {
            AUTH_Gmail_OAuth1_3leg oAuth = new AUTH_Gmail_OAuth1_3leg();
            // Create gmail access request.
            oAuth.GetRequestToken();
            // Get authorization URL, let user login to gmail and get verification code.
            System.Diagnostics.Process.Start(oAuth.GetAuthorizationUrl());
            Console.WriteLine("Enter(menu->Paste) gmail verification code:");
            // Get access token which is needed for accessing gmail API.
            oAuth.GetAccessToken(Console.ReadLine().Trim());

            using (IMAP_Client imap = new IMAP_Client())
            {
                imap.Logger = new LumiSoft.Net.Log.Logger();
                imap.Logger.WriteLog += delegate(object sender, LumiSoft.Net.Log.WriteLogEventArgs e)
                {
                    Console.WriteLine("log: " + e.LogEntry.Text);
                };
                //imap.Connect("imap.gmail.com", WellKnownPorts.IMAP4_SSL, true);
                imap.Connect("imap.gmail.com", WellKnownPorts.IMAP4, false);

                string email = oAuth.GetUserEmail();
                imap.Authenticate(new AUTH_SASL_Client_XOAuth(email, oAuth.GetXOAuthStringForImap(email)));
                imap.SelectFolder("inbox");

                Console.WriteLine("\r\n\r\n----- You are connected now. Press enter for exit.");
                Console.ReadLine();
            }

            return View();
        }
Пример #2
0
        public void connect()
        {
            IMAP_Client client = new IMAP_Client();
            client.Connect("imap.yandex.ru", 995, true);
            client.Login("testkeepteam1", "testmail");
            client.SelectFolder("Inbox");

            /*    client
            client.Fetch(false,
                     IMAP_t_SeqSet.Parse("2:1"),
                     new IMAP_t_Fetch_i() {new IMAP_t_Fetch_i_Envelope()},
                     new EventHandler(Of LumiSoft.Net.EventArgs(Of IMAP_r_u))(AddressOf client_Fetch));

               */
        }
Пример #3
0
 public IMAP_Client loginAs(string login, string password)
 {
     IMAP_Client client = new IMAP_Client();
     client.Connect("imap.yandex.ru", 993, true);
     client.Login(login, password);
     client.SelectFolder("INBOX");
     Console.Out.WriteLine("метод loginAS");
     return client;
 }
Пример #4
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();
            }
        }
Пример #5
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");
            }
        }
Пример #6
0
        public override void Open()
        {
            Logger.Debug("Opening IMAP connection {0}", LogSource.Channel, UniqueId);

            if (!(channelState == ChannelState.Closed || channelState == ChannelState.Broken))
            {
                Logger.Debug("SUCCESS Connection was allready open {0}", LogSource.Channel, UniqueId);

                return;
            }

            channelState = ChannelState.Connecting;
            client = new IMAP_Client();

            if ("/Settings/Channels/LoggerEnabled".AsKey(false))
            {
                client.Logger = new LumiSoft.Net.Log.Logger();
                client.Logger.WriteLog += (sender, e) => Logger.Debug(e.LogEntry.Text.Replace("{", "{{").Replace("}", "}}"), LogSource.Channel);
            }

            try
            {
                client.Connect(Hostname, Port, IsSecured);

                channelState = ChannelState.Connected;
            }
            catch (Exception ex)
            {
                channelState = ChannelState.Closed;

                Logger.Debug("Unable to connect to server. Exception = {0}", LogSource.Channel, ex);

                throw new ChannelException("Unable to connect to server", ex);
            }

            Logger.Debug("SUCCESS Opening connection {0}", LogSource.Channel, UniqueId);
        }
Пример #7
0
        /// <summary>
        /// Intializes destination object. Makes it ready to store messages messages into it.
        /// </summary>
        private void InitDestination()
        {
            #region LumiSoft Mail Server User

            // LumiSoft Mail Server User
            if(m_DestinationType == 0){
                m_pDestinationObject = m_pUser.VirtualServer.Users.GetUserByName(m_pDestination_TypeLSUser_User.Text);
            }

            #endregion

            #region IMAP

            // IMAP
            else if(m_DestinationType == 1){
                IMAP_Client imap = new IMAP_Client();
                imap.Connect(m_pDestination_TypeIMAP_Host.Text,(int)m_pDestination_TypeIMAP_Port.Value,m_pDestination_TypeIMAP_UseSSL.Checked);
                imap.Login(m_pDestination_TypeIMAP_User.Text,m_pDestination_TypeIMAP_Password.Text);
                m_pDestinationObject = imap;
            }

            #endregion

            #region ZIP

            // ZIP
            else if(m_DestinationType == 2){
                ZipOutputStream zipFile = new ZipOutputStream(File.Create(m_pDestination_TypeZIP_File.Text));
                zipFile.SetLevel(9);
                m_pDestinationObject = zipFile;
            }

            #endregion

            else{
                throw new Exception("Invalid destination type '" + m_DestinationType.ToString() + "' !");
            }
        }
Пример #8
0
        /// <summary>
        /// Intializes source object. Makes it ready to get messages info and messages.
        /// </summary>
        private void InitSource()
        {
            #region LumiSoft Mail Server User

            // LumiSoft Mail Server User
            if(m_SourceType == 0){
                m_pSourceObject = m_pUser.VirtualServer.Users.GetUserByName(m_pSource_TypeLSUser_User.Text);
            }

            #endregion

            #region IMAP

            // IMAP
            else if(m_SourceType == 1){
                IMAP_Client imap = new IMAP_Client();
                imap.Connect(m_pSource_TypeIMAP_Host.Text,(int)m_pSource_TypeIMAP_Port.Value,m_pSource_TypeIMAP_UseSSL.Checked);
                imap.Login(m_pSource_TypeIMAP_User.Text,m_pSource_TypeIMAP_Password.Text);
                m_pSourceObject = imap;
            }

            #endregion

            #region ZIP

            // ZIP
            else if(m_SourceType == 2){
                m_pSourceObject = new ZipFile(m_pSource_TypeZIP_File.Text);
            }

            #endregion

            else{
                throw new Exception("Invalid source type '" + m_SourceType.ToString() + "' !");
            }
        }
Пример #9
0
 public void Connect(String server, String User, String pass, int port, bool useSSl)
 {
     try
     {
         Client = new IMAP_Client();
         Client.Connect(server, port, useSSl);
         Client.Login(User, pass);
         _IsConnected = true;
     }
     catch (Exception exe)
     {
         throw new EMailException { ExceptionType = EMAIL_EXCEPTION_TYPE.ERROR_ON_CONNECTION, InnerException = exe };
     }
 }
Пример #10
0
        public override void init()
        {
            using (IMAP_Client imap = new IMAP_Client())
            {
                imap.Connect(m_host, m_port);
                imap.Capability();
                imap.Login(m_user, m_pwd);

                var seqSet = LumiSoft.Net.IMAP.IMAP_t_SeqSet.Parse("1:*");
                var imap_t_Fetch_i = new IMAP_t_Fetch_i[]{
                         new IMAP_t_Fetch_i_Envelope(),//邮件的标题、正文等信息
                         new IMAP_t_Fetch_i_Flags(),//此邮件的标志,应该是已读未读标志
                         new IMAP_t_Fetch_i_InternalDate(),//貌似是收到的日期
                         new IMAP_t_Fetch_i_Rfc822(),//Rfc822是标准的邮件数据流,可以通过Lumisoft.Net.Mail.Mail_Message对象解析出邮件的所有信息(不确定有没有附件的内容)。
                         new IMAP_t_Fetch_i_Uid()
                };

                imap.SelectFolder("INBOX");
                EventHandler<LumiSoft.Net.EventArgs<IMAP_r_u>> lumisoftHandler = new EventHandler<LumiSoft.Net.EventArgs<IMAP_r_u>>(Fetchcallback);
                imap.Fetch(false, seqSet, imap_t_Fetch_i, lumisoftHandler);
            }
        }
Пример #11
-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);
        }