GetFolder return null by using FolderNamespace
Hello Jeffrey
I am trying to open a trash folder by using Enum MailKit.Specialfolder in MS Office Home Outlook. But I got null finally. Is it correct behaviour? Should I get the trash folder by using name or it is a bug? Should I wait for a new version?
Here is an extract from my code:
IMailFolder trashFolder = ImapClient.GetFolder(SpecialFolder.Trash); //trashFolder == null in result
Best regards.
I probably should have designed this API to throw an exception in this case instead of returning null, but what this means is that your IMAP server either does not support the XLIST or SPECIAL-USE extensions -or- it doesn't define a Trash folder.
The basic IMAP protocol does not define where to find any folder except the Inbox.
The XLIST and SPECIAL-USE extensions both define similar ways of figuring out which folder is the Trash folder, Drafts folder, etc.
Towards the end of the "Using IMAP" section in the README.md file, there's a paragraph explaining a possible alternative to use when the IMAP server does not support SPECIAL-USE or XLIST.
The example code shows how you might try and find the "Sent" folder, but you can adapt the logic for finding the Trash folder instead.
I think that Microsoft's email products use the name "Deleted Items", but you could search for a folder named "Delete Items", "Trash", etc.
Hope that helps.