public void supprMailIMAP(string userName, string psw, string service, bool ssl, int port, string mailsupprBegin, string mailsupprEnd)
        {
            IMAP_Client imapc      = loginMail(userName, psw, service, ssl, port);
            var         folderlist = imapc.GetFolders(null);

            imapc.SelectFolder("INBOX");
            var folder = imapc.SelectedFolder;
            var seqSet = IMAP_t_SeqSet.Parse("@begin:@end".Replace("@begin", mailsupprBegin).Replace("@end", mailsupprEnd));
            var items  = new IMAP_t_Fetch_i[]
            {
                new IMAP_t_Fetch_i_Envelope(),
                new IMAP_t_Fetch_i_Uid(),
                new IMAP_t_Fetch_i_Flags(),
                new IMAP_t_Fetch_i_InternalDate(),
                new IMAP_t_Fetch_i_Rfc822()
            };

            try
            {
                imapc.StoreMessageFlags(true, seqSet, IMAP_Flags_SetType.Add, new IMAP_t_MsgFlags(new string[] { IMAP_t_MsgFlags.Deleted }));
            }
            catch
            {
            }
            imapc.Disconnect();
        }
示例#2
0
        /// <summary>
        /// Deletes specified message.
        /// </summary>
        /// <param name="uid">Message UID.</param>
        private void DeleteMessage(long uid)
        {
            try {
                /* NOTE: In IMAP message deleting is 2 step operation.
                 *  1) You need to mark message deleted, by setting "Deleted" flag.
                 *  2) You need to call Expunge command to force server to dele messages physically.
                 */

                var sequenceSet = IMAP_t_SeqSet.Parse(uid.ToString());
                _client.StoreMessageFlags(true, sequenceSet, IMAP_Flags_SetType.Add, new IMAP_t_MsgFlags(IMAP_t_MsgFlags.Deleted));
                _client.Expunge();
            }
            catch (Exception ex) {
                //Debug.WriteLine(ex.Message);
                AppJournal.Write("EmailImapTransport: DeleteMessage: " + ex.Message);
            }
        }