C # Gmail settings set in POP3

Hy

I get emails from my gmail account using these libraries http://mailsystem.codeplex.com/ .

Everything is fine (I get the number of messages and a list of all messages) when I launch my application for the first time after I set "Enable POP for all mail" to "OK" in "Forwarding and POP / IMAP", in the menu settings. But when I run it again, messages are not received. And if I log in again and configure POP for all mail, the application works again.

I think I need to install "enable POP for all mail" programmatically before I run the code for the received messages.

Does anyone know how I can do this programmatically in C # and asp.net?

The code I'm using is:

Pop3Client pop = new Pop3Client();
        try
        {
            Label7.Text = string.Format("Connection to the pop 3 server : {0}", "pop.gmail.com ");
            pop.ConnectSsl("pop.gmail.com", 995, TextBox4.Text, TextBox5.Text);

            Label7.Text += string.Format("Message Count: {0}", pop.MessageCount.ToString());
            MessageCollection mc = new MessageCollection();
            for (int n = 1; n < pop.MessageCount + 1; n++)
            {
                Message newMessage = pop.RetrieveMessageObject(n);
                mc.Add(newMessage);

                 Label7.Text += string.Format("Message ({0}) : {1} ", n.ToString(), newMessage.Subject);
            }
        }

        catch (Pop3Exception pexp)
        {
            Label7.Text = string.Format("Pop3 Error: {0} ", pexp.Message);
        }

        catch (Exception ex)
        {
            Label7.Text = string.Format("Failed: {0} ", ex.Message);
        }

        finally
        {
            if (pop.IsConnected)
            {
                pop.Disconnect();
            }
        }

ActiveUp.Net.Mail , .

+3
1

IMAP4 POP3

POP3 . . .

IMAP4 . . , IMAP4.

+2

Source: https://habr.com/ru/post/1766748/


All Articles