473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reading email in C# .Net

5 New Member
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 21176
PRR
750 Recognized Expert Contributor
Look into SmtPop.Net or this article
Mar 25 '09 #2
jive
5 New Member
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 Recognized Expert Specialist
Frinny did a nice article here.
Mar 26 '09 #4
PRR
750 Recognized Expert Contributor
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
thanhvyit
1 New Member
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
templecitytest
1 New Member
pop.Open ("localhost", "110", "mylogin", "mypasword");

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

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

Similar topics

4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
4
by: Magix | last post by:
Hi, I would like to check if the data file is empty or not before reading it. How should I achieve that ? fseek/ftell ? ....fopen process here(..) if filesize is 0 // mean empty data printf...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
4
by: Greg Smith | last post by:
I have an old application that analyzes the data in the event log on one of our servers. I would like to convert it to C#. Does anybody know of any examples of reading the event log on a remote...
2
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { ...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
1
by: Need Helps | last post by:
Hello. I'm writing an application that writes to a file a month, day, year, number of comments, then some strings for the comments. So the format for each record would look like:...
2
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.