Retrieving attachments from an email account with .NET.

I want the free library for .NET to receive attachments from an account (for example, gMail or others) via imap4 (optional) and save them in a folder.

Ideally, this will allow me to get a list of them and download only some of them (filtering by extension, name and / or size) and be free.

I already did this with a trial version of EAGetMail , but for what I am trying to buy an unlimited version of this library is not quite suitable (I did not know that this functionality itself was one of those who had a limited time).

--- [edit - Higuchi] ---

I am using the following code:

Dim cl As New Pop3Client()
        cl.UserName = "marcelo.f.ramires@gmail.com"
        cl.Password = "mypassword"
        cl.ServerName = "pop.gmail.com"
        cl.AuthenticateMode = Pop3AuthenticateMode.Pop
        cl.Ssl = False
        cl.Authenticate() //takes a while, but passes even if there a wrong password

        Dim mg As Pop3Message = cl.GetMessage(1) //gives me an exception: Message = "Pop3 connection is closed"

UPDATE: setting the port to 995 gives me a "Response TimeOut" exception

, . ?

+3
1

, , IMAP4, , , POP3 , :

http://csharpmail.codeplex.com/

POP3, ( Gmail) IMAP.

Pop3Client, POP3, ExecuteList, ExecuteTop .. , - .

, , , .

. :

  • Pop3Client.Port 995. , , Gmail POP3.
  • Pop3Client.Authenticate bool, , . , , .

2. , :

Using client As New Pop3Client
    client.UserName = "username@gmail.com"
    client.Password = "[insert password here]"
    client.ServerName = "pop.gmail.com"
    client.AuthenticateMode = Pop3AuthenticateMode.Pop
    client.Ssl = True ' NOTICE: in your example code you have False here '
    client.Port = 995
    client.Authenticate()

    Dim messageList = client.ExecuteList()
    Console.WriteLine("# Messages: {0}", messageList.Count)
End Using

, .

3: ! , POP Gmail? , !

  • Gmail "" ( ).
  • "" " POP/IMAP".
  • " POP" , POP-.
  • " " .
+5

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


All Articles