469,268 Members | 920 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

Reading email in C# .Net

5
I'm using SmtpPop.dll to read emails the code:
Expand|Select|Wrap|Line Numbers
  1. POP3Client pop = new SmtPop.POP3Client();
  2. pop.Open ("pop.gmail.com", 25, "myaccname", "mypass");
  3. SmtPop.POPMessageId[] messages = pop.GetMailList(); //The code breaks here
  4.  
and i get this exception:
Expand|Select|Wrap|Line Numbers
  1. Waiting +OK. Received :502 5.5.1 Unrecognized command. f31sm10153311fkf.15
  2.  
pls help.
thx in advance.
Mar 25 '09 #1
6 20914
PRR
750 Expert 512MB
Look into SmtPop.Net or this article
Mar 25 '09 #2
jive
5
yes i read those and still cant figure it out
a code sample of connecting to the gmail server would really help
Mar 25 '09 #3
tlhintoq
3,525 Expert 2GB
Frinny did a nice article here.
Mar 26 '09 #4
PRR
750 Expert 512MB
You can look here
There is a sample code there
Expand|Select|Wrap|Line Numbers
  1. // connect to pop server
  2.     SmtPop.POP3Client pop = new SmtPop.POP3Client ();
  3.       pop.Open ("localhost", "110", "mylogin", "mypasword");
  4.  
  5.     // get messages list from pop server
  6.     SmtPop.POPMessageId[] messages = pop.GetMailList ();
  7.  
  8.     if (messages != null)
  9.      {
  10.           // Walk attachment list
  11.           foreach (SmtPop.POPMessageId id in messages)
  12.           {
  13.               SmtPop.POPReader reader = pop.GetMailReader (id.Id);
  14.               SmtPop.MimeMessage msg = new SmtPop.MimeMessage ();
  15.  
  16.               // read message
  17.               msg.Read (reader);
  18.               if (msg.Attachments != null)
  19.               {
  20.                   // do something with first attachment
  21.                 SmtPop.MimeAttachment attach = msg.Attachments[0];
  22.                   if (attach.Filename == "data")
  23.                   {
  24.                       // read data from attachment
  25.                       Byte[] b = Convert.FromBase64String (attach.Body);
  26.  
  27.                       System.IO.MemoryStream mem = new System.IO.MemoryStream (b, false);
  28.                       BinaryFormatter f = new BinaryFormatter ();
  29.                     DataClass data = (DataClass) f.Deserialize (mem); 
  30.                     mem.Close();
  31.                 }                          
  32.  
  33.                 //delete message
  34.                 pop.Dele (id.Id);
  35.                   }
  36.               }
  37.           }
  38.     }
  39.  
  40.     pop.Quit ();
  41.  

SDK
link.
Mar 26 '09 #5
Hi, thanks lot of for your code about read email from pop server.

Now, i have a problem. With your code was posted i can get all emails from server. With the first read, it is nothing. But when i read emails again, i must read all emails while most of emails i have readed before. How to only read emails unread status???

Thanks,
VyPhan
Sep 3 '09 #6
pop.Open ("localhost", "110", "mylogin", "mypasword");

error in this line it shows timeout problem
Dec 22 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Xah Lee | last post: by
4 posts views Thread by Oliver Knoll | last post: by
4 posts views Thread by Magix | last post: by
6 posts views Thread by KevinD | last post: by
4 posts views Thread by Greg Smith | last post: by
2 posts views Thread by Sabin Finateanu | last post: by
21 posts views Thread by JoKur | last post: by
2 posts views Thread by Jean-Marie Vaneskahian | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.