如何使用MailKit版本4.3.0删除邮箱?
下面是我使用的代码:
...
//Ensure that the inbox folder is open
if (!Inbox.IsOpen)
{
//Here never enters
Inbox.Open(FolderAccess.ReadWrite);
}
//Delete message from inbox
try
{
//Here is where I get the exception
Inbox.AddFlags(uid, MessageFlags.Deleted, true);
Inbox.Expunge();
}
catch (Exception ex)
{
//Console.WriteLine($"Error al intentar borrar el correo con UID {uid}: {ex.Message}");
}
finally
{
//Close inbox folder after deleting message
if (Inbox.IsOpen)
{
Inbox.Close();
}
}
...
当我调试代码时,它抛出了下一个异常: MailKit.FolderNotOpenException: 'The folder is not currently open in read-write mode.'个
我向ChatGPT询问了该异常,并告诉我可以使用以下代码以读写模式打开,但Visual Studio表示属性IsWritable不存在:
if (!Inbox.IsOpen || !Inbox.IsWritable)
{
Inbox.Open(FolderAccess.ReadWrite);
}
我怎样才能做到这一点呢?