Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I was using this Limilabs Mail.dll and after deleting the mails retrieved from it first time through this code Now I am receiving no mails.
Below is the code:
string conn = @"Data source=(local);Initial Catalog=fyp;Integrated Security=true";
SqlConnection con = new SqlConnection(conn);
string add, name;
byte[] buffer;
using (Pop3 pop3 = new Pop3())
    pop3.Connect("", 995, true);  // or ConnectSSL for SSL
    pop3.Login("username", "password");

    // Receive all messages and display the subject
    MailBuilder builder = new MailBuilder();
    foreach (string uid in pop3.GetAll())
        IMail email = builder.CreateFromEml(

        foreach (MailBox m in email.From)
            add = m.Address;
            name = m.Name;

            string date = (email.Date).ToString();
            string sub = (email.Subject);
            string text = (email.Text);

            foreach (MimeData mime in email.Attachments)
                mime.Save(@"d:\" + mime.SafeFileName);
                buffer = mime.Data;

                string qry = "insert into retmail_2 values (@sub,@text,@date)";
                SqlCommand cmd = new SqlCommand(qry, con);
                cmd.Parameters.AddWithValue("@sub", sub);
                cmd.Parameters.AddWithValue("@text", text);
                cmd.Parameters.AddWithValue("@from", add);
                cmd.Parameters.AddWithValue("@name", name);
                cmd.Parameters.AddWithValue("@date", date);
                cmd.Parameters.AddWithValue("@attch", buffer);
                int g = cmd.ExecuteNonQuery();



Now it is retrieving no mails so guys can you tell me some permanent solution other than this because it is retrieving no mails now.Thing is all the mails that r retrieved they are stored in a datagridview given in the windows form. Now on row cell click event it was shows mails also when it retrieves mails it inserts them into a table made in sqlserver 2008 its in which there is an autogenerated integer type uid. Now on debugging it is showing uid -1 in gridview and nothing is retrieved in the database.
i thought that the mails are not retrieving from the mail server.Thats why this is happening. I dont know other way to retrieve mails from a server.
Help me PLZ.
Updated 1-May-14 6:27am
Sunasara Imdadhusen 1-May-14 6:30am    
Where is code for sending email to the user??
Richard MacCutchan 1-May-14 7:00am    
Where is the code for reading the mail from the server?
Mohammad Reza Valadkhani 10-May-14 8:45am    
There is no Code for Retrieve Emails from your inbox !!!! you missed it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900