0 votes

How to get email from sent item folder?

by (8.8k points)

1 Answer

0 votes
 
Best answer

You'll need to use IMAP component for that, as POP3 protocol doesn't support folders.

The key thing is to select sent folder:

var common = new CommonFolders(imap.GetFolders());
imap.Select(common.Sent);

Here's the full listing:

using Limilabs.Mail;
using Limilabs.Client.IMAP;

class Program
{
    static void Main(string[] args)
    {
        using(Imap imap = new Imap())
        {
            imap.Connect("imap.example.com");   
            // or ConnectSSL for SSL

            imap.UseBestLogin("user", "password");

            var common = new CommonFolders(imap.GetFolders());
            imap.Select(common.Sent);

            List<long> uids = imap.GetAll();

            foreach (long uid in uids)
            {
                string eml = imap.GetMessageByUID(uid);
                IMail email = new MailBuilder()
                    .CreateFromEml(eml);

                Console.WriteLine(email.Subject);
                Console.WriteLine(email.Text);
            }
            imap.Close();
        }
    }
};
by (297k points)
selected by
...