pop3

This is a discussion on pop3 within the C# Programming forums, part of the General Programming Boards category; How can i connect to a pop3 server and show how many e-mails i have, and notify if i new ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    16

    pop3

    How can i connect to a pop3 server and show how many e-mails i have, and notify if i new e-mail arrived.

    Thanks,
    Miranda

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    You'll have to use the TcpClient class.

    TcpClient.Connect to connect to the server probably on the standard 110 port

    Server should respond with an +OK (successful) message.

    Next you'll have to send two messages. One for USER and one for PASS. The server should successfully acknowledge both messages.

    Finally, you'll have to send messages for LIST and RETR messages.

    I would suggest you start off with a console app that just successfully connects to the server and then add the USER, PASS messages and then LIST RETR messages. In other words, build it one step at a time.

    Finally, if a GUI is desired, you can always "wrap" your console code in GUI code.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    Ok, i made the connection, but how can i receive a notice when a new e-mail arrive? Would be a notice at the time it arrived, if i'm not connected with the program and connect it later, i won't receive the notice.
    How can i do that?
    Last edited by miranda; 01-05-2006 at 08:20 PM.

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    16

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    The Pop3 protocol does not have a facility to provide a callback.

    You need to query the POP3 server, see what's there, then decide if there's something new to report to the user

  6. #6
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    Yeah, i just dont't know how to know if the message is NEW or NOT got it?

  7. #7
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    What Fordy is saying is that POP3 itself doesn't tell you what's been read or not. You have to keep a record of what's been read and check the list yourself.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Another approach would be to use the NetStream class to occassionally query (set up a timer) the POP3 server with POP3 "STAT". You'll probably have to split up the total messages and total size from what is returned. Thus, if total messages differs from previous query then "you've got mail".

  9. #9
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    yeah but the program only tell if i have new messages, and if i delete some messages in my webmail?

    numberoldmessages - numberofnewmessages right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fetchmail with pop3
    By Jaguar in forum Tech Board
    Replies: 3
    Last Post: 09-26-2005, 09:33 AM
  2. Free PoP3
    By afreedboy in forum Tech Board
    Replies: 18
    Last Post: 11-30-2003, 11:56 PM
  3. free pop3 library
    By vollys in forum Tech Board
    Replies: 2
    Last Post: 11-02-2003, 04:31 AM
  4. Questions on POP3
    By theLukerBoy in forum Tech Board
    Replies: 3
    Last Post: 11-05-2002, 07:30 AM
  5. free POP3 email
    By dbaryl in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 08-09-2002, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21