Hi DZ,

thats it! You gave me the conclusive tip with the TOP command. In my  
application I'll keep the connection open, load down all headers and then  
decide to delete on the server!

Thanks a lot for your work!

Kind regards, Michael

Am Wed, 09 Nov 2005 17:17:47 +0100 hat DZ-Jay <[EMAIL PROTECTED]> geschrieben:

> Michael Lorenz wrote:
>> Hi All,
>>
>> for a special program (delete my messages on the server) I want to get  
>> all
>> headers in a list with their message ids. Then I want to list it on a
>> CheckBoxList and after that I want to delete them. The receiving of a
>> complete mail is no problem, the  deltion also, but how can I get only  
>> the
>> message headers and Ids? I don't want to receive the whole message.
>
> Here's what you do, in POP3 commands:
> 1. Issue a "UIDL" command with no arguments.  This will return a list of
> the message number and their Unique IDentifier (the msg ID from the POP3
> server).
>
> Alternatively, if your server does not support the UIDL command (I
> believe its not required by the RFC, you will then have to issue a LIST
> command, then a TOP command (see below) to get the headers, parse the
> headers, and extract the Message-ID header from it.
>
> Notice that there is a difference between the UID of the POP3 server and
> the Message-ID header, which is inserted by the SMTP server.  The UID is
> easier to find (by using the UIDL command), so use it if its available.
>
> 2. You store this list locally so that you can reference the messages on
> the server later.
>
> 3. Issue a "TOP" command.  The TOP command has 2 arguments, the message
> number (from the LIST or UIDL command) and the amount of message body
> lines to return.  If you give zero as the body lines, it will return
> only the headers.
>
> 4. When you are ready to delete a message, send the "DELE" command with
> the message number.
>
> Keep in mind that the message numbers might change when the mailbox is
> updated.  If you are going to keep the session open while the user
> selects which messages to delete, you will have no problems.  But if you
> plan on disconnecting, be aware that the message list might have been
> updated by a separate session, so as an added integrity measure you
> should verify that the message number still belongs to that particular
> message by issuing a "UIDL" command with the message number as an
> argument, and comparing it with the UID you stored locally.  If they
> match, you can safely delete the message.  If they don't, you should
> issue a new UIDL command to get the list again and update the message
> numbers of your local UID list.  This is important, and a major error on
> some amateur mail software built by independent developers (I know that
> The Bat! had this problem back in version 1.x).
>
> As an example, your POP3 session will look like this:
>
> NOTE:
>       '<' = received from server
>       '>' sent to server
>
>
> < +OK POP3 Server Ready
>  > UIDL
> < +OK unique-id listing follows
> < 1 B0208052198.MSG
> < 2 B0208062359.MSG
> < 3 B0208062986.MSG
> < 4 B0208063013.MSG
> < 5 B0208067844.MSG
> < .
>
>  > TOP 1 0
> < +OK
> {Headers of #1 go here... SNIP!}
> < .
>
>  > TOP 2 0
> < +OK
> {Headers of #2 go here... SNIP!}
> < .
>
>  > TOP 3 0
> < +OK
> {Headers of #3 go here... SNIP!}
> < .
>
>  > TOP 4 0
> < +OK
> {Headers of #4 go here... SNIP!}
> < .
>
>  > TOP 5 0
> < +OK
> {Headers of #5 go here... SNIP!}
> < .
>
>  > UIDL 1
> < +OK 1 B0208052198.MSG
>
>  > DELE 1
> < +OK message 1 deleted
>
>  > QUIT
> < +OK POP3 server signing off (4 messages left)
>
>       dZ.
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to