当前位置: 首页>>代码示例>>C#>>正文


C# Pop3Client.Authenticate方法代码示例

本文整理汇总了C#中OpenPop.Pop3.Pop3Client.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# Pop3Client.Authenticate方法的具体用法?C# Pop3Client.Authenticate怎么用?C# Pop3Client.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenPop.Pop3.Pop3Client的用法示例。


在下文中一共展示了Pop3Client.Authenticate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestMethodInitialize

 public void TestMethodInitialize()
 {
     settings = new TestSettings();
     client = new Pop3Client();
     client.Connect(settings.Pop3Server, settings.Pop3Port, settings.Pop3UseSSL);
     client.Authenticate(settings.Pop3UserName, settings.Pop3Password);
 }
开发者ID:ielcoro,项目名称:KarmakracyDispatcher,代码行数:7,代码来源:ReadPop3Test.cs

示例2: ReadAllEmails

        private void ReadAllEmails()
        {
            // The client disconnects from the server when being disposed
            using (Pop3Client client = new Pop3Client())
            {
                // Connect to the server
                client.Connect(EmailConfiguration.Pop3, EmailConfiguration.PopPort, true, 1800, 1800, removeCertificateCallback);

                // Authenticate ourselves towards the server
                client.Authenticate(EmailConfiguration.Email, EmailConfiguration.EmailPwd);

                // Get the number of messages in the inbox
                int messageCount = client.GetMessageCount();

                _systemLogger.Tell(string.Format("Total messages found: {0}", messageCount));

                // Most servers give the latest message the highest number
                for (int i = messageCount; i > 0; i--)
                {
                    var msg = client.GetMessage(i);

                    // Now return the fetched messages
                    _emailProcessorActor.Tell(new EmailMessage(){Subject = msg.Headers.Subject, Date = msg.Headers.Date});
                }
            }
        }
开发者ID:cpoDesign,项目名称:MailToTrello,代码行数:26,代码来源:EmailReaderActor.cs

示例3: Test

        public void Test()
        {
            const string hostName = "pop.gmail.com";
            int port = 995;
            bool useSsl = true;
            string userName = "USER";
            string password = "PASSWORD";

            using(Pop3Client client = new Pop3Client())
            {
                // Connect to the server
                client.Connect(hostName, port, useSsl);

                // Authenticate ourselves towards the server
                client.Authenticate(userName, password);

                // Get the number of messages in the inbox
                int messageCount = client.GetMessageCount();

                // We want to download all messages
                List<Message> allMessages = new List<Message>(messageCount);

                // Messages are numbered in the interval: [1, messageCount]
                // Ergo: message numbers are 1-based.
                // Most servers give the latest message the highest number
                for (int i = messageCount; i > 0; i--)
                {
                    allMessages.Add(client.GetMessage(i));
                }

                allMessages.ForEach(m=>Console.WriteLine("Display name: {0}", m.Headers.From.DisplayName));
            }
        }
开发者ID:constructor-igor,项目名称:TechSugar,代码行数:33,代码来源:Pop3ClientTests.cs

示例4: FetchAllMessages

        public void FetchAllMessages()
        {
            // The client disconnects from the server when being disposed
            using (Pop3Client client = new Pop3Client())
            {
                // Connect to the server
                client.Connect(_hostName, _port, true);

                // Authenticate ourselves towards the server
                client.Authenticate(_username, _password);

                // Get the number of messages in the inbox
                int messageCount = client.GetMessageCount();

                // We want to download all messages
                List<Message> allMessages = new List<Message>(messageCount);

                // Messages are numbered in the interval: [1, messageCount]
                // Ergo: message numbers are 1-based.
                for (int i = 1; i <= messageCount; i++)
                {
                    allMessages.Add(client.GetMessage(i));
                }
            }
        }
开发者ID:macki,项目名称:razem,代码行数:25,代码来源:EmailManager.cs

示例5: GetAllMessages

        //Connect to gmail, get emails and ad it to a MessageList
        public static List<OpenPop.Mime.Message> GetAllMessages(string hostname, int port, bool ssl, string username, string password)
        {
            try
            {
                Pop3Client client = new Pop3Client();

                    if (client.Connected)
                    {
                        client.Disconnect();
                    }

                    client.Connect(hostname, port, ssl);
                    client.Authenticate(username, password);

                    int messageCount = client.GetMessageCount();

                    List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);

                    for (int i = messageCount; i > messageCount - 5; i--)
                    {
                        allMessages.Add(client.GetMessage(i));
                    }

                    return allMessages;
                }

            catch(Exception ex)
            {
                MessageBox.Show("You have written username or password wrong or something else has happened! Program will not keep going, please open it again, thank you : " + ex.Message);
                Thread.CurrentThread.Abort();
                //EmailClient.
            }

            return null;
        }
开发者ID:kayabirch,项目名称:H5Email,代码行数:36,代码来源:LogedIn.cs

示例6: HasMessages

        public override bool HasMessages()
        {
            if (!pop3Client.Connected)
            {
                pop3Client.Dispose();
                pop3Client = new Pop3Client();
                pop3Client.Connect(HostName, Port, useSSL);
                pop3Client.Authenticate(Login, Password);
            }

            if (0 >= index)
            {
                index = count = pop3Client.GetMessageCount();
                if (0 == index)
                {
                    pop3Client.Disconnect();
                    pop3Client.Dispose();
                    pop3Client = new Pop3Client();
                    pop3Client.Connect(HostName, Port, useSSL);
                    pop3Client.Authenticate(Login, Password);
                }
                //for (int i = count; i >= 1; i -= 1)
            }
            return 0 < index;
        }
开发者ID:wortjanin,项目名称:CallSelector,代码行数:25,代码来源:CallDataProviderImplPop3.cs

示例7: FetchAllMessages

		/// <summary>
		/// Example showing:
		///  - how to fetch all messages from a POP3 server
		/// </summary>
		/// <param name="hostname">Hostname of the server. For example: pop3.live.com</param>
		/// <param name="port">Host port to connect to. Normally: 110 for plain POP3, 995 for SSL POP3</param>
		/// <param name="useSsl">Whether or not to use SSL to connect to server</param>
		/// <param name="username">Username of the user on the server</param>
		/// <param name="password">Password of the user on the server</param>
		/// <returns>All Messages on the POP3 server</returns>
		public static List<Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
		{
			// The client disconnects from the server when being disposed
			using(Pop3Client client = new Pop3Client())
			{
				// Connect to the server
				client.Connect(hostname, port, useSsl);

				// Authenticate ourselves towards the server
				client.Authenticate(username, password);

				// Get the number of messages in the inbox
				int messageCount = client.GetMessageCount();

				// We want to download all messages
				List<Message> allMessages = new List<Message>(messageCount);

				// Messages are numbered in the interval: [1, messageCount]
				// Ergo: message numbers are 1-based.
				// Most servers give the latest message the highest number
				for (int i = messageCount; i > 0; i--)
				{
					allMessages.Add(client.GetMessage(i));
				}

				// Now return the fetched messages
				return allMessages;
			}
		}
开发者ID:JoshKeegan,项目名称:hpop,代码行数:39,代码来源:Examples.cs

示例8: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            using (Pop3Client client = new Pop3Client())
            {
                //Para conectar no servidor do gmail use a porta 995 e SSL
                client.Connect("pop.gmail.com", 995, true);
                //Para conectar no servidor do hotmail use a porta 995 e SSL
                //client.Connect("pop3.live.com", 995, true);
                //usuário e senha para autenticar
                client.Authenticate("luisfelipe.lambert", "sakuda5G");
                //Pega o número de mensagens
                int messageCount = client.GetMessageCount();

                //Instanciar a lista 
                List<Message> mensagens = new List<Message>();
                //Pegar as mensagens
                for (int i = messageCount; i > 0; i--)
                {
                    //Adicionar a mensagem a lista
                    mensagens.Add(client.GetMessage(i));
                }
                //Popular o repeater com as mensagens
                repMensagens.DataSource = mensagens;
                repMensagens.DataBind();
            }
        }
        catch (Exception ex)
        {
            //Caso ocorra algum erro, uma mensagem será exibida na página
            litMensagemErro.Text = ex.ToString();
        }
    }
开发者ID:flviocarvalho,项目名称:conleg,代码行数:34,代码来源:Email.aspx.cs

示例9: GetAllMails

        /* Function to retrive Email from the POP3 Server */
        public void GetAllMails(object sender, DoWorkEventArgs e)
        {
            int percentComplete;

            using(Pop3Client client = new Pop3Client())
            {
                /* Set the Server, Port, ssl and username/password */
                client.Connect(Setting.Default.pop3_server, Setting.Default.pop3_port, Setting.Default.smtp_ssl);
                client.Authenticate(Setting.Default.username, Setting.Default.password);

                int messageCount = client.GetMessageCount();

                Debug.WriteLine(messageCount);

                /* Create a list to contain the messages */
                List<Message> allMessages = new List<Message>();

                /* A loop to calculate the progress of retriving the Emails  */
                for (int i = messageCount; i > 0; i--)
                {
                    allMessages.Add(client.GetMessage(i));
                    percentComplete = Convert.ToInt16((Convert.ToDouble(allMessages.Count) / Convert.ToDouble(messageCount)) * 100);
                    (sender as BackgroundWorker).ReportProgress(percentComplete);
                }
                e.Result =  allMessages;
            }
        }
开发者ID:Nicolai-,项目名称:CSharp_Mail_Client_New,代码行数:28,代码来源:POPClient.cs

示例10: processMail

 public void processMail()
 {
     Logger.info("Проверка почты: ");
     try {
         Pop3Client client = new Pop3Client();
         client.Connect(Settings.Single.smtpServer, 110, false);
         client.Authenticate(Settings.Single.smtpUser, Settings.Single.smtpPassword);
         List<string> msgs = client.GetMessageUids();
         Logger.info(String.Format("Получено {0} сообщений ", msgs.Count));
         for (int i = 0; i < msgs.Count; i++) {
             try {
                 Logger.info("Чтение письма " + i.ToString());
                 Message msg = client.GetMessage(i);
                 List<MessagePart> files = msg.FindAllAttachments();
                 Logger.info(String.Format("Прикреплено {0} файлов", files.Count));
                 if (files.Count == 1) {
                     Logger.info(String.Format("Обработка файла {0}", files[0].FileName));
                     MessagePart file = files[0];
                     string pbrData = file.GetBodyAsText();
                     PBR.getFromText(pbrData);
                 }
             }
             catch (Exception e) {
                 Logger.error("Ошибка при обработке письма " + i);
             }
         }
     }
     catch (Exception e) {
         Logger.error("Ошибка при работе с почтой " + e.ToString());
     }
 }
开发者ID:rj128x,项目名称:AutoOper2016,代码行数:31,代码来源:MailClass.cs

示例11: ConnectToPop3

        private void ConnectToPop3()
        {
            client = new Pop3Client();

            client.Connect(settings.Pop3Server, settings.Pop3Port, settings.Pop3UseSSL);
            client.Authenticate(settings.Pop3UserName, settings.Pop3Password);
        }
开发者ID:ielcoro,项目名称:KarmakracyDispatcher,代码行数:7,代码来源:MailDaemon.cs

示例12: fetchAllMessages

        private static void fetchAllMessages(object sender, DoWorkEventArgs e)
        {
            int percentComplete;

            // The client disconnects from the server when being disposed
            using (Pop3Client client = new Pop3Client())
            {
                // Connect to the server
                //client.Connect("pop.gmail.com", 995, true);
                client.Connect("mail1.stofanet.dk", 110, false);

                // Authenticate ourselves towards the server
                client.Authenticate("2241859m002", "big1234");

                // Get the number of messages in the inbox
                int messageCount = client.GetMessageCount();

                // We want to download all messages
                List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);

                // Messages are numbered in the interval: [1, messageCount]
                // Ergo: message numbers are 1-based.
                // Most servers give the latest message the highest number

                for (int i = messageCount; i > 0; i--)
                {
                    allMessages.Add(client.GetMessage(i));
                    percentComplete = Convert.ToInt16((Convert.ToDouble(allMessages.Count) / Convert.ToDouble(messageCount)) * 100);
                    (sender as BackgroundWorker).ReportProgress(percentComplete);
                }

                // Now return the fetched messages
                e.Result = allMessages;
            }
        }
开发者ID:Graungaard,项目名称:ProgrammeringIII-EmailClient,代码行数:35,代码来源:RecieveMail.cs

示例13: ImportEmails

        //-------------------------------------------------------------------------------------------
        private void ImportEmails(Communication_EmailAccounts account)
        {
            Console.WriteLine("Importing e-mails for " + account.Id + " -- " + account.Host);
               using (Pop3Client client = new Pop3Client())
               {
                    // connect
                    client.Connect(account.Host, account.Port, (account.Type == "pops"));
                    client.Authenticate(account.Username, account.Password);

                    // iterate over the messages
                    int messageCount = client.GetMessageCount();
                    List<Message> allMessages = new List<Message>(messageCount);
                    for (int i = 1; i <= messageCount; i++)
                    {
                         using (WeavverEntityContainer data = new WeavverEntityContainer())
                         {
                              //data.SearchAllTables("asdf");
                              // save to database
                              Message m = (Message) client.GetMessage(i);
                              if (m.MessagePart.IsText)
                              {
                                   Communication_Emails item = new Communication_Emails();
                                   item.From = m.Headers.From.Raw;
                                   item.Subject = m.Headers.Subject;
                                   item.Raw = System.Text.ASCIIEncoding.ASCII.GetString(m.RawMessage);
                                   data.SaveChanges();

                                   client.DeleteMessage(i);
                              }
                         }
                    }
               }
        }
开发者ID:weavver,项目名称:data,代码行数:34,代码来源:Communication_Email.cs

示例14: CallDataProviderImplPop3

 public CallDataProviderImplPop3(ISelectorConfig config)
     : base(config)
 {
     this.pop3Client = new Pop3Client();
     pop3Client.Connect(HostName, Port, useSSL);
     pop3Client.Authenticate(Login, Password);
     NULL_MESSAGE = new CallMessageImpl(pop3Client, 0, this);
     
 }
开发者ID:wortjanin,项目名称:CallSelector,代码行数:9,代码来源:CallDataProviderImplPop3.cs

示例15: GetMessages

        public IEnumerable<MessageDTO> GetMessages(string hostname, int port, bool useSsl, string username,
                                                   string password, int? maxNumber = null)
        {
            var allMessages = new List<MessageDTO>();

            try
            {
                // The client disconnects from the server when being disposed
                using (var client = new Pop3Client())
                {
                    client.Connect(hostname, port, useSsl);

                    client.Authenticate(username, password, AuthenticationMethod.UsernameAndPassword);

                    var maxCount = client.GetMessageCount();

                    //work out subset to take from messages
                    var messageCount = (maxNumber.HasValue && maxNumber < maxCount) ? (maxCount - maxNumber.Value) : 0;

                    //message list is 1 based
                    //loop written backwards so messages are in correct order
                    for (var i = maxCount; i > messageCount; i--)
                    {
                        var currentMessage = client.GetMessage(i);
                        var html = currentMessage.FindFirstHtmlVersion();

                        allMessages.Add(new MessageDTO
                            {
                                Body =
                                    html != null && html.Body != null
                                        ? Encoding.UTF8.GetString(html.Body)
                                        : string.Empty,
                                DateSent = currentMessage.Headers.DateSent,
                                DisplayName = currentMessage.Headers.From.DisplayName,
                                From = currentMessage.Headers.From.Address,
                                Id = currentMessage.Headers.MessageId,
                                Subject = currentMessage.Headers.Subject,
                                Uid = currentMessage.Headers.MessageId
                            });

                    }

                }
            }
            catch (Exception ex)
            {
                var path = Path.GetTempPath();
                var stream = File.OpenWrite(Path.Combine(path, "mailFireErrorLog.log"));

                using (var fileWriter = new StreamWriter(stream))
                {
                    fileWriter.Write(string.Format("Exception occurred: {0} - at {1}", ex.Message, DateTime.Now));
                }
            }
            return allMessages;
        }
开发者ID:James84,项目名称:MailFire,代码行数:56,代码来源:OpenPop3Messaging.cs


注:本文中的OpenPop.Pop3.Pop3Client.Authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。