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("pop.gmail.com", 995, true);
pop3.Login("username", "password");
MailBuilder builder = new MailBuilder();
foreach (string uid in pop3.GetAll())
{
IMail email = builder.CreateFromEml(
pop3.GetMessageByUID(uid));
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);
con.Open();
int g = cmd.ExecuteNonQuery();
con.Close();
}
pop3.Close();
}
}
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.