Cannot get subject from an email from Gmail in C#

104 Views Asked by At

I'm making an application to view the last email sent with the word "Teste" and get its subject into a variable.

It is a Console Application, because I don't need to interact with it.

My code is the following:

using (var client = new OpenPop.Pop3.Pop3Client())
        {
            client.Connect(host, port, useSSl);
            client.Authenticate(username, password);

            // Set conditions
            MailQueryBuilder builder = new MailQueryBuilder();

            // Subject contains "Teste"
            builder.Subject.Contains("Teste");

            // Here is the email of the sender
            builder.From.Contains("[email protected]");

            // Build the query
            MailQuery query = builder.GetQuery();                               
        }

I'm new to programming with POP3, so I don't quite understand how it works. So far I set the conditions and build the query, but from now on I don't know what to do to store the subject in the variable.

0

There are 0 best solutions below