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


C# Pop3Client.DeleteMessage方法代码示例

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


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

示例1: Fetch

 public void Fetch(Action<Message> process)
 {
     var seenUids = File.Exists(seenUidsFile) ? new HashSet<string>(File.ReadAllLines(seenUidsFile)) : new HashSet<string>();
     using (var client = new Pop3Client())
     {
         pop3Authorize(client);
         List<string> messageUids = client.GetMessageUids();
         foreach (var msgInfo in messageUids.Select((uid, index) => new{uid, index}).Where(msgInfo => !seenUids.Contains(msgInfo.uid)))
         {
             try
             {
                 Message message = client.GetMessage(msgInfo.index+1);
                 message.Save(new FileInfo(msgInfo.uid + ".mime"));
                 process(message);
                 seenUids.Add(msgInfo.uid);
             }
             catch(Exception e)
             {
                 log.Error("Error while processing message " + msgInfo + "\r\n" + e);
             }
         }
         File.WriteAllLines(seenUidsFile, seenUids);
         for(int i=messageUids.Count; i>=1; i--) client.DeleteMessage(i);
     }
 }
开发者ID:xoposhiy,项目名称:banality,代码行数:25,代码来源:FetchAllUnseenPop3Client.cs

示例2: 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

示例3: DownloadMailsAndPushToIssueTracker

        private static void DownloadMailsAndPushToIssueTracker()
        {
            var host = Settings.Get("Pop3Host", "");
            var port = Settings.Get("Pop3Port", 110);
            var useSsl = Settings.Get("Pop3UseSsl", false);
            var username = Settings.Get("Pop3Username", "");
            var password = Settings.Get("Pop3Password", "");

            if (host.IsNoE())
            {
                Console.WriteLine("\tNo Pop3Host specified.");
                LogOwnError(new ApplicationException("No Pop3Host specified."));
                return;
            }

            try
            {
                Console.WriteLine("\tConnecting to POP3 server {0}:{1} ({4}) using {2} / {3} ...", host, port, username, password, useSsl ? "SSL" : "no SSL");

                using (var pop3Client = new Pop3Client())
                {
                    pop3Client.Connect(host, port, useSsl);
                    if (username.HasValue())
                        pop3Client.Authenticate(username, password);

                    Console.WriteLine("\tFetching message count ...");
                    var messageCount = pop3Client.GetMessageCount();

                    for (var i = 1; i <= messageCount; i++)
                    {
                        try
                        {
                            Console.WriteLine("\tFetching message {0} / {1} ...", i, messageCount);
                            var message = pop3Client.GetMessage(i);

                            if (PushToIssueTracker(message))
                                pop3Client.DeleteMessage(i);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("\tUnable to fetch or push message: " + ex);
                            LogOwnError(new ApplicationException("Unable to fetch or push message: " + ex.Message, ex));
                        }
                    }

                    pop3Client.Disconnect();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\tUnable to download mails: " + ex);
                LogOwnError(new ApplicationException("Unable to download mails: " + ex.Message, ex));
            }
        }
开发者ID:saxx,项目名称:IssueTracker,代码行数:54,代码来源:Program.cs

示例4: Retrieve

        public void Retrieve()
        {
            var messages = new List<Message>();
            using (var client = new Pop3Client())
            {
                var appSettings = ConfigurationManager.AppSettings;
                client.Connect(appSettings["host"], 110, false);
                client.Authenticate(appSettings["user"], appSettings["pass"], AuthenticationMethod.UsernameAndPassword);
                for (var i = client.GetMessageCount(); i > 0; i--)
                {
                    var message = client.GetMessage(i);
                    messages.Add(message);
            #if (!DEBUG)
                    client.DeleteMessage(i);
            #endif
                }
            }

            _parser.Parse(messages);
        }
开发者ID:Grinderofl,项目名称:ImageHosting,代码行数:20,代码来源:EmailRetriever.cs

示例5: DeleteMessageByMessageId

		/// <summary>
		/// Example showing:
		///  - how to delete fetch an emails headers only
		///  - how to delete a message from the server
		/// </summary>
		/// <param name="client">A connected and authenticated Pop3Client from which to delete a message</param>
		/// <param name="messageId">A message ID of a message on the POP3 server. Is located in <see cref="MessageHeader.MessageId"/></param>
		/// <returns><see langword="true"/> if message was deleted, <see langword="false"/> otherwise</returns>
		public bool DeleteMessageByMessageId(Pop3Client client, string messageId)
		{
			// Get the number of messages on the POP3 server
			int messageCount = client.GetMessageCount();

			// Run trough each of these messages and download the headers
			for (int messageItem = messageCount; messageItem > 0; messageItem--)
			{
				// If the Message ID of the current message is the same as the parameter given, delete that message
				if (client.GetMessageHeaders(messageItem).MessageId == messageId)
				{
					// Delete
					client.DeleteMessage(messageItem);
					return true;
				}
			}

			// We did not find any message with the given messageId, report this back
			return false;
		}
开发者ID:JoshKeegan,项目名称:hpop,代码行数:28,代码来源:Examples.cs

示例6: FetchAllMessages

    /// <summary>
    /// 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>
    /// <param name="deleteImagAfterFetch">If true images on Pop3 will be deleted after beeing fetched</param>
    /// <returns>All Messages on the POP3 server</returns>
    public static List<OpenPop.Mime.Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password, bool deleteImagAfterFetch)
    {
        // The client disconnects from the server when being disposed
        using (Pop3Client client = new Pop3Client())
        {
            // Connect to the server
            client.Connect(hostname, port, useSsl);
            client.Authenticate(username, password);
            int messageCount = client.GetMessageCount();

            // We want to download all messages
            List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);
            for (int i = messageCount; i > 0; i--)
            {
                allMessages.Add(client.GetMessage(i));

                if (deleteImagAfterFetch)
                {
                    client.DeleteMessage(i);
                }
            }
            return allMessages;
        }
    }
开发者ID:micmro,项目名称:emailToKindle,代码行数:34,代码来源:SendEmailAsAttachment.cs

示例7: fetch_messages


//.........这里部分代码省略.........
                {
                    // position of colon
                    pos = subject.IndexOf(":", pos);
                    pos++;
                    // position of close paren
                    int pos2 = subject.IndexOf(")", pos);
                    if (pos2 > pos)
                    {
                        string bugid_string = subject.Substring(pos, pos2 - pos);
                        write_line("BUGID=" + bugid_string);
                        try
                        {
                            int bugid = Int32.Parse(bugid_string);
                            useBugId = true;
                            write_line("updating existing bug " + Convert.ToString(bugid));
                        }
                        catch (Exception e)
                        {
                            write_line("bugid not numeric " + e.Message);
                        }
                    }
                }

                
                // send request to web server
                try
                {
                    HttpClientHandler handler = new HttpClientHandler
                    {
                        AllowAutoRedirect = true,
                        UseCookies = true,
                        CookieContainer = new CookieContainer()
                    };
                    using (var httpClient = new HttpClient(handler))
                    {
                        var loginParameters = new Dictionary<string, string>
                        {
                           { "user", ServiceUsername },
                           { "password", ServicePassword }
                        };

                        HttpContent loginContent = new FormUrlEncodedContent(loginParameters);
                        var loginResponse = await httpClient.PostAsync(LoginUrl, loginContent);
                        loginResponse.EnsureSuccessStatusCode();

                        string rawMessage = Encoding.Default.GetString(mimeMessage.RawMessage);
                        var postBugParameters = new Dictionary<string, string>
                        {
                           { "projectId", Convert.ToString(projectid) },
                           { "fromAddress", from },
                           { "shortDescription", subject},
                           { "message", rawMessage}
                           //Any other paramters go here
                        };
                        if (useBugId)
                        {
                            postBugParameters.Add("bugId", bugidString);
                        }

                        HttpContent bugContent = new FormUrlEncodedContent(postBugParameters);
                        var postBugResponse = await httpClient.PostAsync(InsertBugUrl, bugContent);

                        postBugResponse.EnsureSuccessStatusCode();
                    }
                    if (MessageInputFile == "" && DeleteMessagesOnServer == "1")
                    {
                        write_line("sending POP3 command DELE");
                        client.DeleteMessage(message_number);
                    }
                }
                catch (Exception e)
                {
                    write_line("HttpWebRequest error url=" + InsertBugUrl);
                    write_line(e);
                    write_line("Incrementing total error count");
                    total_error_count++;
                }

                // examine response
                if (total_error_count > TotalErrorsAllowed)
                {
                    write_line("Stopping because total error count > TotalErrorsAllowed");
                    stop();
                }


            }  // end for each message


            if (MessageInputFile == "")
            {
                write_line("\nsending POP3 command QUIT");
                client.Disconnect();
            }
            else
            {
                write_line("\nclosing input file " + MessageInputFile);
            }
        }
    }
开发者ID:jhadwen,项目名称:BugTracker.NET,代码行数:101,代码来源:POP3Main.cs

示例8: fetch_messages


//.........这里部分代码省略.........

                string rawMessage = Encoding.Default.GetString(mimeMessage.RawMessage);
                string post_data = "username=" + HttpUtility.UrlEncode(ServiceUsername)
                                   + "&password=" + HttpUtility.UrlEncode(ServicePassword)
                                   + "&projectid=" + Convert.ToString(projectid)
                                   + "&from=" + HttpUtility.UrlEncode(from)
                                   + "&short_desc=" + HttpUtility.UrlEncode(subject)
                                   + "&message=" + HttpUtility.UrlEncode(rawMessage);

                byte[] bytes = Encoding.UTF8.GetBytes(post_data);


                // send request to web server
                HttpWebResponse res = null;
                try
                {
                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);


                    req.Credentials = CredentialCache.DefaultCredentials;
                    req.PreAuthenticate = true;

                    //req.Timeout = 200; // maybe?
                    //req.KeepAlive = false; // maybe?

                    req.Method = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.ContentLength = bytes.Length;
                    Stream request_stream = req.GetRequestStream();
                    request_stream.Write(bytes, 0, bytes.Length);
                    request_stream.Close();
                    res = (HttpWebResponse)req.GetResponse();
                }
                catch (Exception e)
                {
                    write_line("HttpWebRequest error url=" + Url);
                    write_line(e);
                }

                // examine response

                if (res != null)
                {

                    int http_status = (int)res.StatusCode;
                    write_line(Convert.ToString(http_status));

                    string http_response_header = res.Headers["BTNET"];
                    res.Close();

                    if (http_response_header != null)
                    {
                        write_line(http_response_header);

                        // only delete message from pop3 server if we
                        // know we stored in on the web server ok
                        if (MessageInputFile == ""
                            && http_status == 200
                            && DeleteMessagesOnServer == "1"
                            && http_response_header.IndexOf("OK") == 0)
                        {
                            write_line("sending POP3 command DELE");
                            client.DeleteMessage(message_number);
                        }
                    }
                    else
                    {
                        write_line("BTNET HTTP header not found.  Skipping the delete of the email from the server.");
                        write_line("Incrementing total error count");
                        total_error_count++;
                    }
                }
                else
                {
                    write_line("No response from web server.  Skipping the delete of the email from the server.");
                    write_line("Incrementing total error count");
                    total_error_count++;
                }

                if (total_error_count > TotalErrorsAllowed)
                {
                    write_line("Stopping because total error count > TotalErrorsAllowed");
                    stop();
                }


            }  // end for each message


            if (MessageInputFile == "")
            {
                write_line("\nsending POP3 command QUIT");
                client.Disconnect();
            }
            else
            {
                write_line("\nclosing input file " + MessageInputFile);
            }
        }
    }
开发者ID:jfaquinojr,项目名称:BugTracker.NET,代码行数:101,代码来源:POP3Main.cs

示例9: TestDeleteMessage

		public void TestDeleteMessage()
		{
			const string welcomeMessage = "+OK";
			const string okUsername = "+OK";
			const string okPassword = "+OK";
			const string deleteResponse = "+OK"; // Message was deleted
			const string quitAccepted = "+OK";
			const string serverResponses = welcomeMessage + "\r\n" + okUsername + "\r\n" + okPassword + "\r\n" + deleteResponse + "\r\n" + quitAccepted + "\r\n";

			Stream inputStream = new MemoryStream(Encoding.ASCII.GetBytes(serverResponses));
			MemoryStream outputStream = new MemoryStream();

			Pop3Client client = new Pop3Client();
			client.Connect(new CombinedStream(inputStream, outputStream));
			client.Authenticate("test", "test");

			client.DeleteMessage(5);

			const string expectedOutput = "DELE 5";
			string output = GetLastCommand(new StreamReader(new MemoryStream(outputStream.ToArray())).ReadToEnd());

			// We expected that the last command is the delete command
			Assert.AreEqual(expectedOutput, output);

			client.Disconnect();

			const string expectedOutputAfterQuit = "QUIT";
			string outputAfterQuit = GetLastCommand(new StreamReader(new MemoryStream(outputStream.ToArray())).ReadToEnd());

			// We now expect that the client has sent the QUIT command
			Assert.AreEqual(expectedOutputAfterQuit, outputAfterQuit);
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:32,代码来源:POPClientPositiveTests.cs

示例10: Main

        static void Main(string[] args)
        {
            bool cnx = false;
            String logMail = "[email protected]", logPass = "Espol2015";
            int num = 0, band = 0;
            Message message;
            String subject;
            String notif;

            Console.WriteLine("Verificando conexión a internet...");

            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface nic in nics)
            {
                if (
                    (nic.NetworkInterfaceType != NetworkInterfaceType.Loopback && nic.NetworkInterfaceType != NetworkInterfaceType.Tunnel) &&
                    nic.OperationalStatus == OperationalStatus.Up)
                {
                    networkIsAvailable = true;
                }
            }
            Console.Write("Conexión a Internet: ");
            Console.WriteLine(networkIsAvailable);
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);

            if (networkIsAvailable)
            {

                Console.WriteLine("Subrutina -- Lectura de Eventos Ignorar");
                Console.WriteLine("Solicitando acceso a la cuenta de correo sist_segu_2015");

                Pop3Client pop3Client = new Pop3Client();
                pop3Client.Connect("pop3.live.com", 995, true);
                pop3Client.Authenticate(logMail, logPass);
                cnx = pop3Client.Connected;

                Console.WriteLine("Solicitud de conexión a las " + DateTime.Now);
                Console.WriteLine("Conectando...");

                if (cnx == true)
                {
                    Console.WriteLine("--- Conexión exitosa ---");
                    Console.WriteLine("Se realizó conexión exitosa a las " + DateTime.Now);
                }
                else
                {
                    Console.WriteLine("--- Conexión fallida ---");
                    Console.WriteLine("Fallo de conexión a las " + DateTime.Now);
                    Console.WriteLine("Presione una tecla para salir...");
                    Console.ReadKey();
                    System.Environment.Exit(0);
                }

                num = pop3Client.GetMessageCount();
                Console.WriteLine("Usted tiene {0} correos en su bandeja", num);
                Console.WriteLine("Leyendo correos, buscando notificación IGNORAR...");
                for (int i = 1; i <= num; i++)
                {
                    message = pop3Client.GetMessage(i);
                    subject = message.ToMailMessage().Subject;
                    if (subject == "IGNORAR")
                    {
                        notif = message.ToMailMessage().Body;
                        Console.WriteLine("Contenido del correo: " + notif);
                        pop3Client.DeleteMessage(i);
                        Console.WriteLine("Se ha notificado al programa la captura del evento IGNORAR enviada por el usuario");
                        band = 1;
                    }
                    else
                    {
                        Console.WriteLine("Leyendo {0} correos...", i);
                    }
                }
                if (band == 0)
                {
                    Console.WriteLine("No se han encontrado notificaciones...");
                }

                pop3Client.Disconnect();
                Console.WriteLine("La subrutina fue desconectada a las  " + DateTime.Now);
                Console.WriteLine("Presione una tecla para salir...");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("No hay conexión a Internet, por favor verificar el inconveniente");
                Console.ReadKey();
            }
        }
开发者ID:richardcolleman,项目名称:Video-captura-de-robos-casera,代码行数:89,代码来源:Program.cs

示例11: GetActivationCode

 //-------------------------------------------------------------------------------------------
 private string GetActivationCode()
 {
     using (Pop3Client client = new Pop3Client())
        {
             client.Connect(Helper.GetAppSetting("pop3_server"), 110, false);
             client.Authenticate(Helper.GetAppSetting("pop3_username"), Helper.GetAppSetting("pop3_password"));
             int x = client.GetMessageCount();
             for (int i = 1; i < x + 1; i++)
             {
                  Message msg = client.GetMessage(i);
                  string subj = msg.Headers.Subject;
                  if (subj == "Please activate your Weavver ID")
                  {
                       string activationCode = System.Text.Encoding.GetEncoding("utf-8").GetString(msg.FindFirstHtmlVersion().Body);
                       activationCode = activationCode.Substring(activationCode.IndexOf("Or use the following code:") + 30);
                       activationCode = activationCode.Substring(0, activationCode.IndexOf("<br>"));
                       client.DeleteMessage(i);
                       return activationCode;
                  }
             }
        }
        return null;
 }
开发者ID:weavver,项目名称:moksha,代码行数:24,代码来源:WeavverApp.cs

示例12: TestGetMessageInfosAfterDelete

        public void TestGetMessageInfosAfterDelete()
        {
            // arrange
            const string welcomeMessage = "+OK";
            const string okUsername = "+OK";
            const string okPassword = "+OK";

            const string messageDeleteAccepted = "+OK";

            const string messageUidAccepted = "+OK";
            const string messageUid1 = "1 psycho"; // Message 1 has UID psycho
            const string messageUid2 = "3 lord"; // Message 3 has UID lord
            const string uidListEnded = ".";

            const string messageListAccepted = "+OK 2 messages (320 octets)";
            const string messageSize1 = "1 120";
            const string messageSize2 = "3 200";
            const string messageListEnd = ".";


            const string serverResponses = welcomeMessage + "\r\n" + okUsername + "\r\n" + okPassword + "\r\n"
                + messageDeleteAccepted + "\r\n"
                + messageUidAccepted + "\r\n" + messageUid1 + "\r\n" + messageUid2 + "\r\n" + uidListEnded + "\r\n"
                + messageListAccepted + "\r\n" + messageSize1 + "\r\n" + messageSize2 + "\r\n" + messageListEnd + "\r\n"
                ;

            Stream inputStream = new MemoryStream(Encoding.ASCII.GetBytes(serverResponses));
            Stream outputStream = new MemoryStream();

            // act
            Pop3Client client = new Pop3Client();
            client.Connect(new CombinedStream(inputStream, outputStream));
            client.Authenticate("test", "test");

            client.DeleteMessage(2);
            List<MessageInfo> infos = client.GetMessageInfos();

            // assert
            Assert.AreEqual(2, infos.Count);

            Assert.AreEqual(1, infos[0].Number);
            Assert.AreEqual("psycho", infos[0].Identifier);
            Assert.AreEqual(120, infos[0].Size);

            Assert.AreEqual(3, infos[1].Number);
            Assert.AreEqual("lord", infos[1].Identifier);
            Assert.AreEqual(200, infos[1].Size);
        }
开发者ID:JoshKeegan,项目名称:hpop,代码行数:48,代码来源:POPClientPositiveTests.cs

示例13: GetEmails

        public string GetEmails()
        {
            var returnMessages = new List<string>();
            using (var pop3Client = new Pop3Client())
            {
                var messages = GetNewMessages(pop3Client);
                var messageCount = messages.Count();
                if (messageCount > 0)
                {
                    IMessageRepository messageRepository = new MessageRepository();
                    IMessageRecepientRepository messageRecepientRepository = new MessageRecepientRepository();
                    IMessageAttachmentRepository messageAttachmentRepository = new MessageAttachmentRepository();
                    IPermissionRepository permissionRepository = new PermissionRepository();
                    IChurchRepository churchRepository = new ChurchRepository();
                    IPersonRepository personRepository = new PersonRepository(permissionRepository, churchRepository);

                    IEmailSender emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository);

                    for (var count = 0; count < messageCount; count++)
                    {
                        var mm = messages[count].ToMailMessage();
                        var regex = new Regex(@"##([0-9]*)##");
                        var matches = regex.Matches(mm.Body);
                        if (matches.Count > 0 && matches[0].Groups.Count > 1)
                        {
                            try
                            {
                                int messageId;
                                if (int.TryParse(matches[0].Groups[1].Value, out messageId))
                                {
                                    var originalSender = messageRepository.GetSender(messageId);
                                    if (originalSender != null)
                                    {
                                        var originalReceiver = personRepository.FetchPersonIdsFromEmailAddress(mm.From.Address, originalSender.ChurchId);
                                        var fromPersonId = originalSender.PersonId;

                                        if (originalReceiver.Any())
                                        {
                                            fromPersonId = originalReceiver.First();
                                        }
                                        returnMessages.Add(string.Format("Forwarding reply from {0} for messageId {1} on to {2}", fromPersonId, messageId, originalSender.Email));
                                        emailSender.SendEmail(mm.Subject, mm.Body, Username, originalSender.Email, Username, Password, fromPersonId, originalSender.ChurchId, mm.Attachments);
                                    }
                                    pop3Client.DeleteMessage(count + 1);
                                }
                            }
                            catch (Exception errSending)
                            {
                                returnMessages.Add(errSending.Message);
                                emailSender.SendExceptionEmailAsync(errSending);
                            }
                        }
                    }
                }
            }
            if (!returnMessages.Any())
            {
                return "No replies found";
            }

            var returnMessage = returnMessages.Aggregate(string.Empty, (current, m) => current + (m + "<br/>"));
            _emailService.SendSystemEmail("Replies found", returnMessage);
            return returnMessage;
        }
开发者ID:petermunnings,项目名称:funwithoiky,代码行数:64,代码来源:HomeController.cs

示例14: DeleteMessageByMessageId

        private static bool DeleteMessageByMessageId(string hostname, int port, bool useSsl, string username, string password, string messageId)
        {
            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 on the POP3 server
                int messageCount = client.GetMessageCount();

                // Run trough each of these messages and download the headers
                for (int messageItem = messageCount; messageItem > 0; messageItem--)
                {
                    // If the Message ID of the current message is the same as the parameter given, delete that message
                    if (client.GetMessageHeaders(messageItem).MessageId == messageId)
                    {
                        // Delete
                        client.DeleteMessage(messageItem);
                        return true;
                    }
                }
                // We did not find any message with the given messageId, report this back
                return false;
            }
        }
开发者ID:andrazjelenc,项目名称:Remote-Contol-Over-Mail,代码行数:28,代码来源:Source.cs

示例15: DeleteMessageOnServer

		/// <summary>
		/// Example showing:
		///  - how to delete a specific message from a 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>
		/// <param name="messageNumber">
		/// The number of the message to delete.
		/// Must be in range [1, messageCount] where messageCount is the number of messages on the server.
		/// </param>
		public static void DeleteMessageOnServer(string hostname, int port, bool useSsl, string username, string password, int messageNumber)
		{
			// 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);

				// Mark the message as deleted
				// Notice that it is only MARKED as deleted
				// POP3 requires you to "commit" the changes
				// which is done by sending a QUIT command to the server
				// You can also reset all marked messages, by sending a RSET command.
				client.DeleteMessage(messageNumber);

				// When a QUIT command is sent to the server, the connection between them are closed.
				// When the client is disposed, the QUIT command will be sent to the server
				// just as if you had called the Disconnect method yourself.
			}
		}
开发者ID:JoshKeegan,项目名称:hpop,代码行数:36,代码来源:Examples.cs


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