.NET Framework 2.0For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I am working on retrieving mails from a pop3 server (currently gmail). The code is as below. It can susseccfully connect to the server and authenticate. It fetches the message details by providing it the message number, though i am not sure how does it assign message number. Now the main problem is that i first want to get the header information like message sender, date, subject, attachment info. This information will be shown as a grid to the user and then the user will select a message which will then be retrieved from the server. How do i get the message header information? Please help.
This is only the relevant code, the entire form-specifc code can be easily understood and is not necessary to put here.
Here POPServ.Text could be like pop.gmail.com, User.Text=a valid email account in gamil, Passw.Text = user password
/// Summary description for Form1.
public class POPForm : System.Windows.Forms.Form
Sam! Thank you for the reply. But here i encounter another problem. Against one of the client's test account on gmail i get the following response when i use STAT command:
+OK 0 0\r\n
Which means there are 0 messages in his inbox whereas i can see there are 92 messages when i look into them directly through gmail. There are many unread records as well. What's wrong with the code then? Its really annoying to me. Please help.
Yes i popped messages using my own gmail account. Though there are a couple of other issues but definitely i get the results of STAT, LIST and RETR commands successfully.
quote:Originally posted by Imar
Have you popped messages from Gmail before? I believe by default Gmail only exposes messages through pop since you enabled pop, although you can change that in the settings.....
The problem is that the server response is too slow for dele. It takes about 10 minutes to come back and respond for success. Secondly the dele command requires the quit command at the end so that all updation can be committed to the server:
Here the last line which reads the response from the server for quit command causes an exception that says the software that is running in the host machine closed the connection. When i comment out dele command the quit command successfuly ends the session.
i m using the above code, but its not worked for me. When i m giving username then in the function "ReadMessage" - the variable bytes gets 0 so because of this it come out from While loop and same happens with the password.
i want to access my gmail acount through progrmming (vb.net/C#.net)
but i am facing problem....
plz help me ...
You have to give proper pop server credentials. Like for gmail i have set the server as "pop.gmail.com" and the port as 995. For gmail, you also need to allow accessing pop mails right from your gmail account. There's a link that says "Settings" somewhere on the top which you have to explore a bit. For other servers i am not sure. Are you able to connect to the pop server? Consider the following lines which connect to the server:
sslStream = new SslStream(Server.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServer Certificate), null);
string messageData = ReadMessage(sslStream, false);
Here what i get as a response in messageData is "+OK Gpop ready for requests from ...". Which means the pop server connected successfully. If you get a message like this then you are ok and now you should enter correct email and password in the subsequent calls. Let me know if still not working.