ImapGetSpecialFolder Method |
Namespace: MailBee.ImapMail
This method itself does not make any network queries, it operates on an already retrieved folder list. To get the folder list, use DownloadFolders method.
Once you got the folder, you can use its Name for other operations (like SelectFolder(String), UploadMessage(MailMessage, String, String, String, Boolean, UidPlusResult), etc). Or, if you need to deal with international folder names, it's better to set Utf7EncodeFolderNames to false and pass RawName instead
Note |
---|
If the server does not support special folder flags, this method can be useless. The IMAP server must support SPECIAL-USE or XLIST extension for this to work. |
using System; using MailBee; using MailBee.Mime; using MailBee.ImapMail; class Sample { static void Main(string[] args) { Imap imp = new Imap(); // Logging is cool for debugging. imp.Log.Enabled = true; imp.Log.Filename = @"C:\Temp\log.txt"; imp.Log.Clear(); // Connect/login. imp.Connect("imap.server.com"); imp.Login("user@domain", "password"); // Create a message and fill it with some values (omitted for brevity). MailMessage msg = new MailMessage(); // Get folders. FolderCollection fc = imp.DownloadFolders(); Folder f = imp.GetSpecialFolder(fc, FolderFlags.Sent); if (f != null) { // Upload a message into Sent Items folder. Folder names can be international. imp.Utf7EncodeFolderNames = false; imp.UploadMessage(msg, f.RawName, SystemMessageFlags.Seen); } imp.Disconnect(); } }