For a recent project I found a great tutorial on how to read and manipulate emails using POP3 on Developer Fusion.
Two things you should note when trying this code.
1) POP3 protocol won’t actually delete the email until you call the QUIT command. If your application fails before you call the Disconnect() method, no emails will be deleted.
2) I was unable to view the content of my emails without making a modification to the Response() method. Apparently the buffersize used in the tutorial was not sufficient for the emails I was viewing. The new method I used is posted on the tutorial’s feedback forum by “ddoctor.” It is as follows:
private string Response() { System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); long buffersize = 1024; byte[] serverbuff = new byte[buffersize]; NetworkStream stream = GetStream(); int count = 0; while (true) { byte[] buff = new byte[2]; int bytes = stream.Read(buff, 0, 1 ); if (bytes == 1) { // if serverbuffer is full, double its capacity if (count == buffersize) { byte[] temp = new byte[buffersize * 2]; int i = 0; while (i < buffersize) { temp = serverbuff; i++; } buffersize *= 2; serverbuff = temp; } serverbuff[count] = buff[0]; count++; if (buff[0] == '\n') { break; } } else { break; }; }; }
I have no problems with Retrieving the message number and UID for it using my own code for POP, but how to I read the data from the UID?
I’m new at this.My emails come but Ican’t send out.How do Ifix my email using Smtp and POP3?