Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Check how many emails\bytes in your POP3 account (PB/CC)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check how many emails\bytes in your POP3 account (PB/CC)

    'Checks your POP3 email account and returns how many emails you have and the total size of the emails in bytes
    'the POP3 RFC is at http://www.faqs.org/rfcs/rfc1939.html

    Code:
    #COMPILE EXE 'PB/CC
    
    $SERVER = "127.0.0.1"    'your pop3 server
    $xUSER = "wayne"         'your username
    $xPASS = "password"      'your password
    
    FUNCTION PBMAIN() AS LONG
    ON ERROR RESUME NEXT
    DIM lPos AS LONG
    DIM sBytes AS STRING
    CRLF$ = CHR$(13) & CHR$(10)
      LOCAL hSocket AS LONG
      TCP OPEN PORT 110 AT $SERVER AS hSocket TIMEOUT 10
      IF ERR THEN
        PRINT "Couldn't connect!"; ERR
        EXIT FUNCTION
      END IF
      TCP RECV hSocket, 1024, Buffer$
      STDOUT Buffer$;
      TCP SEND hSocket, "USER " & $xUSER & CRLF$
      TCP RECV hSocket, 1024, Buffer$
      STDOUT Buffer$;
      TCP SEND hSocket, "PASS " & $xPASS & CRLF$
      TCP RECV hSocket, 1024, Buffer$
      STDOUT Buffer$;
      TCP SEND hSocket, "STAT" & CRLF$
      TCP RECV hSocket, 1024, Buffer$
      lPos = INSTR(5,Buffer$," ")
      sBytes = RIGHT$(Buffer$, LEN(Buffer$) - lPos)
      sBytes = LEFT$(sBytes, LEN(sBytes) - 2)
      STDOUT "You have " & MID$(Buffer$, 5, lPos - 5) & " messages (" & sBytes & " bytes)"
      CLOSE hSocket
    END FUNCTION


    ------------------
    -

  • #2
    'Works without the timeout 10 which may
    'produce an error 24 on some systems.
    'Error messages don't display so added an error trap.
    'Checks your POP3 email account and returns how many emails you have
    'and the total size of the emails in bytes
    'the POP3 RFC is at http://www.faqs.org/rfcs/rfc1939.html]
    Code:
    #COMPILE EXE 'PB/CC
    
    $SERVER = "127.0.0.1"    'your pop3 server
    $xUSER = "wayne"         'your username
    $xPASS = "password"      'your password
    
    FUNCTION PBMAIN() AS LONG
      ON ERROR GOTO PBMainErrorTrap
      DIM lPos AS LONG
      DIM sBytes AS STRING
      DIM n AS LONG
      CRLF$ = CHR$(13) & CHR$(10)
      LOCAL hSocket AS LONG
    n=10:  TCP OPEN PORT 110 AT $SERVER AS hSocket
    
    n=20:  TCP RECV hSocket, 1024, Buffer$
      STDOUT Buffer$;
    n=30: TCP SEND hSocket, "USER " & $xUSER & CRLF$
    n=40:  TCP RECV hSocket, 1024, Buffer$
      STDOUT Buffer$;
    n=50:  TCP SEND hSocket, "PASS " & $xPASS & CRLF$
    n=60:  TCP RECV hSocket, 1024, Buffer$
      STDOUT Buffer$;
    n=70:  TCP SEND hSocket, "STAT" & CRLF$
    n=80:  TCP RECV hSocket, 1024, Buffer$
      lPos = INSTR(5,Buffer$," ")
      sBytes = RIGHT$(Buffer$, LEN(Buffer$) - lPos)
      sBytes = LEFT$(sBytes, LEN(sBytes) - 2)
      STDOUT "You have " & MID$(Buffer$, 5, lPos - 5) & " messages (" & sBytes & " bytes)"
    n=90:  CLOSE hSocket
    EndProgram:
      SLEEP 3000
    EXIT FUNCTION
    PBMAINErrorTrap:
      PRINT "Error";ERR; "at line"n
      RESUME EndProgram
    END FUNCTION
    ------------------

    Comment

    Working...
    X