c# - Getting attachments from a mail account with .NET -
I have to get an attachment from an account for .NET to a free library (like Gmail, or others) via imap4 (Not necessary), and save them to a folder.
Ideally this will allow me to get a list of them, and download only a few given people (filtering based on extension, name, and / or size) and get free .
I have already done a trial version of this, but I am not quite suitable for trying to try to buy an unlimited version of this library (I do not know that this functionality is limited Was one of those with time).
--- [edit - hygi] ---
I am using the following code:
New POP3 client Dim cl () 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 little while, but even goes a wrong password gets the Pope 3 messages = cl.GetMessage (1) // gives me an exception: message = "pop 3 connection is closed "
UPDATE: Setting port to 995 gives me a "Response Timeout" exception
As a comment, I'm having some problems while trying to connect and receive an email first. Any help?
Well, I know that you specified IMAP4, but I thought I offered it any type of In case I do POP3 is an option, because it has been useful to me:
This library provides access to POP3 mails, in which many e- Mail services (including Gmail) offer new IMAP additions.
The core class is Pop3Client
, which provides access to POP3 functions such as ExecuteList
, ExecuteTop
, etc. . What I am specifically saying about this - scanning and downloading actants.
If you decide that you can use after some time and need further guidance, then let me know.
UPDATE : In response to your updated question, I have some initial suggestions:
-
Pop3Client.Port
Property for 995 I know that GPL uses for POP3. -
Pop3Client.Authenticate
gives me a fewbool
to assume that the authentication was successful or not.
UPDATE 2 : After you call the method to know whether you have tried this at home with the following settings, you can check this value You can. And it worked for me:
Using the new POP3 client client as client. User name = "username@gmail.com" client Password = "[Enter password here]" client.ServerName = "pop Gmail.com" client.AuthenticateMode = Pop3AuthenticateMode.Pop client.Ssl = True 'notice: in your example code you have the wrong' client.port = 995 client .authenticate () Dim messageList = client.ExecuteList () Console.WriteLine ()
Try these settings and see if they work for you.
UPDATE 3 : One more thing! Have you made sure that enable POP for your Gmail account? If not, you have to do this!
- From your Gmail Inbox, select "Settings").
- From the settings page, click on the tab labeled "Forwarding and Pop / IAPAP".
- In the pop download section, select one of the radio buttons to enable POP mail.
- Click "Save Changes" below.
Comments
Post a Comment