コード例 #1
0
        public async Task Delete(ConfigModel conf, User user, MailWindow inbox)
        {
            using (ImapClient client = new ImapClient())
            {
                await client.ConnectAsync(conf.ImapServer, conf.ImapPort);

                client.Authenticate(user.Mail, user.Password);
                var Folder = client.GetFolder(ListMessages.fold);
                Folder.Open(MailKit.FolderAccess.ReadWrite);

                if (client.Capabilities.HasFlag(ImapCapabilities.SpecialUse))
                {
                    Deleting content = new Deleting("Are you sure? Your message will be move into trash folder.");
                    content.ShowDialog();
                    bool result = content.result;
                    if (result == true)
                    {
                        var trash = client.GetFolder(SpecialFolder.Trash);
                        Folder.MoveTo(Message.SelectedMails, trash);
                        new ListMessages().Refresh(user, conf, inbox);
                    }
                }
                else
                {
                    Deleting content = new Deleting("Are you sure your IMAP Server do not support trash folder. Message wil be deleted ");
                    bool     result  = content.result;
                    if (result == true)
                    {
                        Folder.AddFlags(Message.SelectedMails, MailKit.MessageFlags.Deleted, false);
                        new ListMessages().Refresh(user, conf, inbox);
                    }
                }
            }
        }