Jump to content
mLipok

POP3.au3 UDF

Recommended Posts

Here I found a usefull UDF for POP3.

I modified this UDF.

You can download it from download section.

POP3_v2.jpg.f349c1b3a1841cfc8782bdfdc720


Below you see old description:

Spoiler

 

Here I found a usefull UDF for POP3.

I decide to refresh this UDF so you can now use _POP3_Ex.au3 , it is still not finished yet, but any comments are welcome (I hope can help me to finish):

_POP3_Ex.au3:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#Region _POP3_Ex.au3 - INDEX
;===============================================================================
;===============================================================================
; Name ..........: _POP3_Ex.au3
; Author: .......: Apzo - Luc HENNINOT <lhenninot@nordnet.fr>
; Author: .......: Tipulatoid, MrCreatoR - _POP3_EML_Parser()
; Modified ......: Thorsten Willert (thorsten [dot] willert [at] gmx [dot] de)
; Modified ......: Oscar
; Modified ......: mLipok
; Date ..........: 2015/02/09
; Version .......: based on 1.03
; AutoIt ........: v3.3.10.2++
;===============================================================================
#cs
    Original UDF:
    http://www.autoitscript.com/forum/index.php?showtopic=22838
    Basic functions for AU3 Scripts, based on the 1939 RFC ( http://www.ietf.org/rfc/rfc1939.txt ).

    Standard for the Format of ARPA-Internet Text Messages ( https://tools.ietf.org/html/rfc822 )
    ; 4.  MESSAGE SPECIFICATION
    ;   4.1.  SYNTAX
    ; 5.  DATE AND TIME SPECIFICATION
    ;   5.1.  SYNTAX

    POP3 AUTHentication command ( https://www.ietf.org/rfc/rfc1734.txt )

    Include version : 0.99 (March 2006, 9th).
    Author : Apzo - Luc HENNINOT <lhenninot@nordnet.fr>
    Modified : Thorsten Willert (thorsten [dot] willert [at] gmx [dot] de)
    Modified : mLipok    http://www.autoitscript.com/forum/user/10673-mlipok/
    (Function names Changed, Variables names Changed, added new functions, added Quoted-printable.au3, Script CleanUp, $g__bPOP3_TRACE and $g__vPOP3_ISCONNECTED Removed)
    Requires AU3 v3.3.10.2+ and UDF: Quoted-printable.au3
#ce

#EndRegion _POP3_Ex.au3 - INDEX

#Region _POP3_Ex.au3 - Include
#include-once
#include <StringConstants.au3>
#include <FileConstants.au3>
#include <array.au3>
#include "Quoted-printable.au3"
#EndRegion _POP3_Ex.au3 - Include

#Region _POP3_Ex.au3 - Global Constants and Enums

; -- _POP3 error codes, sent by SetError. Use @error to display it. --
Global Enum _
        $POP3_ERROR_OK = 0, _
        $POP3_ERROR, _
        $POP3_ERROR_TCPCONNECT_FAILED, _
        $POP3_ERROR_SERVER_RESPONSE_TIMEOUT, _
        $POP3_ERROR_ALREADY_CONNECTED, _
        $POP3_ERROR_NOT_CONNECTED, _
        $POP3_ERROR_NO_AUTH, _
        $POP3_ERROR_TCPRECV_TIMEOUT, _
        $POP3_ERROR_USER_REFUSED, _
        $POP3_ERROR_PASSWD_REFUSED, _
        $POP3_ERROR_ERR_RESPONSE, _
        $POP3_ERROR_NO_OK_RESPONSE, _
        $POP3_ERROR_STAT_BADRESPONSE, _
        $POP3_ERROR_NO_TCP_RESPONSE, _
        $POP3_ERROR_STAT_REFUSED, _
        $POP3_ERROR_LIST_REFUSED, _
        $POP3_ERROR_RSET_REFUSED, _
        $POP3_ERROR_RETR_REFUSED, _
        $POP3_ERROR_QUIT_REFUSED, _
        $POP3_ERROR_DELE_REFUSED, _
        $POP3_ERROR_TOP_REFUSED, _
        $POP3_ERROR_UIDL_REFUSED, _
        $POP3_ERROR_NOOP_REFUSED

;-- _POP3 vars --
Global Const _
        $POP3_OK = '^\+OK'; Regexp syntax

#EndRegion _POP3_Ex.au3 - Global Constants and Enums

#Region _POP3_Ex.au3 - Global variables
Global $g__iPOP3_SOCKET
#EndRegion _POP3_Ex.au3 - Global variables

#Region _POP3_Ex.au3 - Example

;~ _POP3_Example()

Func _POP3_Example()
    If _POP3_ServerConnect('POP3.server.url') Then
        If _POP3_ServerLogIn("UserName", "Password") Then
            Local $aInfo = _POP3_Info()
            _POP3_RFC_QUIT()
            _POP3_ServerDisconnect()
            _ArrayDisplay($aInfo)
        EndIf
    EndIf
EndFunc   ;==>_POP3_Example
#EndRegion _POP3_Ex.au3 - Example

#Region _POP3_Ex.au3 - rfc1939 Functions ; http://www.ietf.org/rfc/rfc1939.txt

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_DELE
; Description ...: Delete msg n-msg_number.
; Syntax ........: _POP3_RFC_DELE($iMsg)
; Parameter(s): .: $iMsg - msg-number
; Return Value ..: Success - server response
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 15:24:41 CET 2010
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_RFC_DELE($iMsg)
    If _POP3_ServerIsAuth() Then
        __POP3_Cmd("DELE " & $iMsg)
        If @error Then Return SetError(@error, 0, 0)

        Local $sRet = __POP3_WaitTcpResponse()
        If @error Then
            Return SetError($POP3_ERROR_NO_TCP_RESPONSE, 0, 0)
        Else
            Return $sRet
        EndIf
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_RFC_DELE

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_LIST
; Description ...: Returns an array with the msg number and its size (octets)
; Syntax ........: _POP3_RFC_LIST([$iMsg = -1])
; Parameter(s): .: $iMsg - Optional: (Default = -1) :
; | -1 = all
; Return Value ..: Success - array[n][2]
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert, Oscar
; Date ..........: Thu Feb 24 23:00:26 CET 2010
; Link ..........:
; Related .......: _POP3_RFC_UIDL
; Example .......: No
; ==============================================================================
Func _POP3_RFC_LIST($iMsg = -1)
    If _POP3_ServerIsAuth() Then
        Local $aRet[1][2], $aTMP2
        Local $sAddMsg = ""

        If $iMsg <> -1 Then
            $sAddMsg = " " & $iMsg
        EndIf

        ; Send List
        Local $sRet = __POP3_Cmd("LIST" & $sAddMsg)
        If @error Then Return SetError(@error, 0, 0)

        While $iMsg = -1 And Not StringRegExp($sRet, "\r\n\.\r\n")
            $sRet = $sRet & __POP3_WaitTcpResponse()
            If @error Then Return SetError($POP3_ERROR_NO_TCP_RESPONSE, 0, 0)
        WEnd

        $sRet = StringRegExpReplace($sRet, '.+?message.+\(.+\)\r\n', @LF) ; Yahoo-Support, by Oscar

        ; Stripping useless infos for complete listing
        If $iMsg = -1 Then
            $sRet = StringMid($sRet, 2, StringLen($sRet) - 6)
        Else
            $sRet = StringMid($sRet, 1, StringLen($sRet) - 2)
        EndIf

        Local $aTMP = StringSplit(StringStripCR($sRet), @LF)

        Local $iE = UBound($aTMP)
        ReDim $aRet[$iE][2]
        $aRet[0][0] = $iE - 1
        For $i = 1 To $iE - 1
            $aTMP2 = StringSplit($aTMP[$i], " ", 2)
            $aRet[$i][0] = $aTMP2[0]
            $aRet[$i][1] = $aTMP2[1]
        Next

        Return $aRet
    EndIf
EndFunc   ;==>_POP3_RFC_LIST

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_NOOP
; Description ...: Actually, does nothing.
; Syntax ........: _POP3_RFC_NOOP()
; Parameter(s): .: -
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 11:22:36 CET 2010
; Remark(s) .....: The most interesting command from RFC 1939 ;)
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_RFC_NOOP()
    If _POP3_ServerIsAuth() Then
        ; Send NOOP
        __POP3_Cmd("NOOP")
        If @error Then Return SetError($POP3_ERROR_USER_REFUSED, 0, 0)
        Return 1
    EndIf
EndFunc   ;==>_POP3_RFC_NOOP

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_QUIT
; Description ...: Validates your actions (dele for example) and stops the connection as it should.
; Syntax ........: _POP3_RFC_QUIT()
; Parameter(s): .: -
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 11:25:00 CET 2010
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_RFC_QUIT()
    If _POP3_ServerIsAuth() Then
        __POP3_Cmd("QUIT")
        If @error Then Return SetError(@error, 0, 0)
        Return 1
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_RFC_QUIT

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_RETR
; Description ...: Downloads the according message
; Syntax ........: _POP3_RFC_RETR([$iMsg = -1])
; Parameter(s): .: $iMsg - Optional: (Default = -1) :
; | -1 = newest
; Return Value ..: Success - string
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 17:23:03 CET 2010
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_RFC_RETR($iMsg = -1)
    If _POP3_ServerIsAuth() Then
        If $iMsg = -1 Then
            Local $aStat = _POP3_RFC_STAT()
            If Not @error Then $iMsg = $aStat[0]
        EndIf
        ; Send Retr
        Local $sRet = __POP3_Cmd("RETR " & $iMsg)
        If @error Then Return SetError(@error, 0, 0)

        ; Downloading until final dot and cariage return.
        While Not StringRegExp($sRet, "\r\n\.\r\n")
            $sRet = $sRet & __POP3_WaitTcpResponse()
            If @error Then Return SetError($POP3_ERROR_NO_TCP_RESPONSE, 0, 0)
        WEnd

        Return $sRet
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_RFC_RETR

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_RSET
; Description ...: Withdraw changes, such as dele orders
; Syntax ........: _POP3_RFC_RSET()
; Parameter(s): .: -
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 11:34:52 CET 2010
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_RFC_RSET()
    If _POP3_ServerIsAuth() Then
        ; Send RSET
        __POP3_Cmd("RSET")
        If @error Then Return SetError(@error, 0, 0)
        Return 1
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_RFC_RSET

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_STAT
; Description ...: Gets the number of messages in the pop3 account (array[1]) and the size(array[2]) in octets
; Syntax ........: _POP3_RFC_STAT()
; Parameter(s): .: -
; Return Value ..: Success - array
; Failure - array[-1,-1]
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Fri Jan 15 09:54:17 CET 2010
; Link ..........:
; Related .......: _POP3_MsgCnt
; Example .......: No
; ==============================================================================
Func _POP3_RFC_STAT()
    Local $aRet[2] = [-1, -1]
    If _POP3_ServerIsAuth() Then
        ; Send STAT
        Local $sRet = __POP3_Cmd("STAT")
        If @error Then Return SetError(@error, 0, 0)

        $sRet = StringStripWS($sRet, 3)
        $aRet = StringSplit($sRet, " ", 2)
        If IsArray($aRet) Then
            Return $aRet
        Else
            Return SetError($POP3_ERROR_STAT_BADRESPONSE, 0, $aRet)
        EndIf
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, $aRet)
    EndIf
EndFunc   ;==>_POP3_RFC_STAT

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_TOP
; Description ...: Retreives the mail headers, and the X first lines of the message
; Syntax ........: _POP3_RFC_TOP([$iMsg = -1[, $iLines = 0]])
; Parameter(s): .: $iMsg - Optional: (Default = -1) :
; | -1 : newest
; $iLines - Optional: (Default = 0) :
; Return Value ..: Success - string
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 17:26:42 CET 2010
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_RFC_TOP($iMsg = -1, $iLines = 0)
    If _POP3_ServerIsAuth() Then
        If $iMsg = -1 Then
            Local $aStat = _POP3_RFC_STAT()
            If Not @error Then $iMsg = $aStat[0]
        EndIf
        ; Send Top
        Local $sRet = __POP3_Cmd("TOP " & $iMsg & " " & $iLines)
        If @error Then Return SetError(@error, 0, 0)

        ; Downloading until final dot and cariage return.
        While Not StringRegExp($sRet, "\r\n\.\r\n")
            $sRet = $sRet & __POP3_WaitTcpResponse()
            If @error Then Return SetError($POP3_ERROR_NO_TCP_RESPONSE, 0, 0)
        WEnd
        Return $sRet
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_RFC_TOP

; #FUNCTION# ===================================================================
; Name ..........: _POP3_RFC_UIDL
; Description ...: Same as _POP3_RFC_LIST(), but with UIDL identifiers instead of message size.
; Syntax ........: _POP3_RFC_UIDL([$iMsg = -1])
; Parameter(s): .: $iMsg - Optional: (Default = -1) :
; Return Value ..: Success - array[n][2]
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 16:51:30 CET 2010
; Link ..........:
; Related .......: _POP3_RFC_LIST
; Example .......: No
; ==============================================================================
Func _POP3_RFC_UIDL($iMsg = -1)
    If _POP3_ServerIsAuth() Then
        Local $aRet[1][2], $aTMP2
        Local $sAddMsg = ""

        If $iMsg <> -1 Then $sAddMsg = " " & $iMsg

        ; Send List
        Local $sRet = __POP3_Cmd("UIDL " & $sAddMsg)
        If @error Then Return SetError(@error, 0, 0)

        While $iMsg = -1 And Not StringRegExp($sRet, "\r\n\.\r\n")
            $sRet = $sRet & __POP3_WaitTcpResponse()
            If @error Then Return SetError($POP3_ERROR_NO_TCP_RESPONSE, 0, 0)
        WEnd

        ; Stripping useless infos for complete listing
        If $iMsg = -1 Then
            $sRet = StringMid($sRet, 2, StringLen($sRet) - 6)
        Else
            $sRet = StringMid($sRet, 1, StringLen($sRet) - 2)
        EndIf

        Local $aTMP = StringSplit(StringStripCR($sRet), @LF)

        Local $iE = UBound($aTMP)
        ReDim $aRet[$iE][2]
        $aRet[0][0] = $iE - 1
        For $i = 1 To $iE - 1
            $aTMP2 = StringSplit($aTMP[$i], " ", 2)
            $aRet[$i][0] = $aTMP2[0]
            $aRet[$i][1] = $aTMP2[1]
        Next

        Return $aRet
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_RFC_UIDL

#EndRegion _POP3_Ex.au3 - rfc1939 Functions ; http://www.ietf.org/rfc/rfc1939.txt

#Region _POP3_Ex.au3 - UDF Function
; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_Info
; Description ...: Returns an array with the specified informations about all mails
; Syntax ........: _POP3_Info([$v_Info = Default[, $iNumberOfMessages = Default]])
; Parameters ....: $v_Info              - [optional] A variant value. Default is Default. String or array
;                  $iNumberOfMessages   - [optional] An integer value. Default is Default.
; Return values .:
;                  Success - array (Default: array[date,from,to,subject])
;                  Failure - 0
; Author ........: Thorsten Willert
; Modified ......: mLipok
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _POP3_Info($v_Info = Default, $iNumberOfMessages = Default)
    If _POP3_ServerIsAuth() Then
        If $v_Info = Default Then
            Local $aFiledNames[4] = ["Date", "From", "To", "Subject"]
        ElseIf IsArray($v_Info) Then
            $aFiledNames = $v_Info
        Else
            $aFiledNames = StringSplit($v_Info, ',', $STR_NOCOUNT)
        EndIf

        Local $iMsgCnt = _POP3_MsgCnt()
        If @error Then Return SetError(@error, 0, 0)

        If $iNumberOfMessages <> Default Then
            ; TODO
        EndIf

        Local $sTMP_EML, $aTMP_EML_Fields
        Local $iFieldsCnt = UBound($aFiledNames)

        If $iMsgCnt > 0 Then
            Local $aRet[$iMsgCnt + 1][$iFieldsCnt]
            $aRet[0][0] = $iMsgCnt
            For $iMsg = 1 To $iMsgCnt
                $sTMP_EML = _POP3_RFC_TOP($iMsg)
                If @error Then Return SetError(@error, 0, 0)
                For $iField = 0 To $iFieldsCnt - 1
                    $aTMP_EML_Fields = StringRegExp($sTMP_EML, '(?i)\n' & $aFiledNames[$iField] & ':\s*(.*?)\R', 3)
                    If Not @error Then $aRet[$iMsg][$iField] = $aTMP_EML_Fields[0]
                Next
            Next
            Return $aRet
        EndIf

        Return SetError($POP3_ERROR, 0, 0)
    Else
        Return SetError($POP3_ERROR_NO_AUTH, 0, 0)
    EndIf
EndFunc   ;==>_POP3_Info

; #FUNCTION# ===================================================================
; Name ..........: _POP3_ServerConnect
; Description ...: Connect to the POP3 server.
; Syntax ........: _POP3_ServerConnect($sServer [, $iPort = 110]])
; Parameter(s): .: $sServer - pop3 server
; $iPort - Optional: (Default = 110) :
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert, mLipok
; Date ..........: Fri Jan 15 18:37:29 CET 2010
; Link ..........:
; Related .......: _POP3_ServerLogIn()
; Example .......: No
; ==============================================================================
Func _POP3_ServerConnect($sServer, $iPort = 110)
    If Not _POP3_ServerIsConnected() Then
        If $iPort = 995 Then
            _POP3_ConsoleDebugError("_POP3_ServerConnect: Error: SSL not supported ..." & @CRLF)
            Return SetError(1, 0, _POP3_ServerIsConnected(False))
        EndIf

        TCPStartup()
        If @error Then
            Return SetError($POP3_ERROR_TCPCONNECT_FAILED, @error, _POP3_ServerIsConnected(False))
        EndIf

        ; Basic name to IP conversion
        _POP3_ConsoleDebug("_POP3_ServerConnect: connecting to: (" & $sServer & "  - using port: " & $iPort & ") ")
        If StringRegExp($sServer, "[a-zA-Z]") Then
            Local $sServerIP = TCPNameToIP($sServer)
            _POP3_ConsoleDebug($sServer & " >> " & $sServerIP & @CRLF)
            $sServer = $sServerIP
        EndIf

        $g__iPOP3_SOCKET = TCPConnect($sServer, $iPort)
        If @error Then
            _POP3_ConsoleDebugError("_POP3_ServerConnect: Error: " & @error & @CRLF)
            Return SetError($POP3_ERROR_TCPCONNECT_FAILED, 0, _POP3_ServerIsConnected(False))
        EndIf

        ; We need a first OK from pop3 server
        __POP3_WaitForOK()
        If @error Then
            Return SetError($POP3_ERROR_NO_OK_RESPONSE, 0, _POP3_ServerIsConnected(False))
        Else
            Return _POP3_ServerIsConnected(True)
        EndIf
    Else
        Return SetError($POP3_ERROR_ALREADY_CONNECTED, 0, _POP3_ServerIsConnected())
    EndIf

EndFunc   ;==>_POP3_ServerConnect

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_ServerLogIn
; Description ...: Login to POP3 Conneted server
; Syntax ........: _POP3_ServerLogIn($sUserName, $sPasswd)
; Parameters ....: $sUserName              - A string value.
;                  $sPasswd             - A string value.
; Return values .: None
; Author ........: Lipok
; Modified ......:
; Remarks .......:
; Related .......: _POP3_ServerConnect()
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_ServerLogIn($sUserName, $sPasswd)
    If _POP3_ServerIsConnected() Then

        ; Send user
        __POP3_Cmd("USER " & $sUserName)
        If @error Then
            Return SetError($POP3_ERROR_USER_REFUSED, 0, _POP3_ServerIsAuth(False))
        EndIf

        ; Send passwd
        __POP3_Cmd("PASS " & $sPasswd)
        If @error Then
            Return SetError($POP3_ERROR_PASSWD_REFUSED, 0, _POP3_ServerIsAuth(False))
        EndIf

        Return SetError(0, 0, _POP3_ServerIsAuth(True))

    Else
        Return SetError($POP3_ERROR_NOT_CONNECTED, 0, _POP3_ServerIsAuth(False))
    EndIf
EndFunc   ;==>_POP3_ServerLogIn


; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_ServerIsConnected
; Description ...: Set/Check POP3 Connection Status
; Syntax ........: _POP3_ServerIsConnected([$bState = Default])
; Parameters ....: $bState              - [optional] A binary value. Default is Default = do not change nothing just return Current status.
; Return values .: Status, current or just set
; Author ........: mLipok
; Modified ......:
; Remarks .......: Default Status is False
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_ServerResponseTimeOut($iTimeOut = Default)
    Local Static $iServerResponseTimeOut = 60000
    If Not IsNumber($iTimeOut) Or Not StringIsDigit($iTimeOut) Then SetError(1, 0, $iServerResponseTimeOut)

    If $iTimeOut <> Default Then
        $iServerResponseTimeOut = $iTimeOut
    EndIf
    Return $iServerResponseTimeOut
EndFunc   ;==>_POP3_ServerResponseTimeOut

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_ServerIsAuth
; Description ...: Set/Check whether user is loged to the POP3 server
; Syntax ........: _POP3_ServerIsAuth([$bState = Default])
; Parameters ....: $bState              - [optional] A binary value. Default is Default = do not change nothing just return Current status.
; Return values .: Status, current or just set
; Author ........: mLipok
; Modified ......:
; Remarks .......: Default Status is False
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_ServerIsAuth($bState = Default)
    Local Static $bIsAuth = False
    If $bState <> Default Then
        If $bState = True Then
            $bIsAuth = True
        Else
            $bIsAuth = False
        EndIf
    EndIf
    Return $bIsAuth
EndFunc   ;==>_POP3_ServerIsAuth

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_ServerIsConnected
; Description ...: Set/Check POP3 Connection Status
; Syntax ........: _POP3_ServerIsConnected([$bState = Default])
; Parameters ....: $bState              - [optional] A binary value. Default is Default = do not change nothing just return Current status.
; Return values .: Status, current or just set
; Author ........: mLipok
; Modified ......:
; Remarks .......: Default Status is False
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_ServerIsConnected($bState = Default)
    Local Static $bIsConnected = False
    If $bState <> Default Then
        If $bState = True Then
            $bIsConnected = True
        Else
            _POP3_ServerIsAuth(False)
            $bIsConnected = False
        EndIf
    EndIf
    Return $bIsConnected
EndFunc   ;==>_POP3_ServerIsConnected

; #FUNCTION# ===================================================================
; Name ..........: _POP3_ServerDisconnect
; Description ...: Shuts down connection to POP3 server.
; Syntax ........: _POP3_ServerDisconnect()
; Parameter(s): .: -
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 11:15:16 CET 2010
; Remark(s) .....: Use _POP3_RFC_QUIT to exit !!
; Link ..........:
; Related .......:
; Example .......: No
; ==============================================================================
Func _POP3_ServerDisconnect()
    If _POP3_ServerIsConnected() Then
        TCPCloseSocket($g__iPOP3_SOCKET)
        TCPShutdown()
        _POP3_ServerIsConnected(False)
        Return SetError(0, 0, 1)
    Else
        _POP3_ServerIsConnected(False)
        Return SetError($POP3_ERROR_NOT_CONNECTED, 0, 1)
    EndIf
EndFunc   ;==>_POP3_ServerDisconnect

; #FUNCTION# ===================================================================
; Name ..........: _POP3_MsgCnt
; Description ...: Returns the number of messages
; Syntax ........: _POP3_MsgCnt()
; Parameter(s): .: -
; Return Value ..: Success - number of messages
; Failure - -1
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Fri Jan 15 09:56:20 CET 2010
; Link ..........:
; Related .......: _POP3_RFC_STAT
; Example .......: NO
; ==============================================================================
Func _POP3_MsgCnt()
    Local $a = _POP3_RFC_STAT()
    Return SetError(@error, 0, $a[0])
EndFunc   ;==>_POP3_MsgCnt

#EndRegion _POP3_Ex.au3 - UDF Function

#Region _POP3_Ex.au3 - _EML_ Functions

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_SaveToFile
; Description ...:
; Syntax ........: _POP3_EML_SaveToFile($iMsg, $sEML_FileFullPath)
; Parameters ....: $iMsg                - An integer value.
;                  $sEML_FileFullPath   - A string value. FileFullPath to save EML file.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_SaveToFile($iMsg, $sEML_FileFullPath)
    Local $sEML = _POP3_RFC_RETR($iMsg)
    If Not @error Then
        _POP3_ConsoleDebug(StringStripCR($sEML) & @CR)
        Local $hEML_File = FileOpen($sEML_FileFullPath, $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8_FULL)
        FileWrite($hEML_File, $sEML)
        FileClose($hEML_File)
    Else

    EndIf
EndFunc   ;==>_POP3_EML_SaveToFile

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_GetDate
; Description ...:
; Syntax ........: _POP3_EML_GetDate($sEML_Content)
; Parameters ....: $sEML_Content        - A string value.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_GetDate($sEML_Content)
    Local $aDate = StringRegExp($sEML_Content, '(?i)(?:\A|\R)Date: (\V+)', 3)
    If UBound($aDate) Then
        Return SetError(0, 0, $aDate[0])
    EndIf
    Return SetError(1, 0, '')
EndFunc   ;==>_POP3_EML_GetDate

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_GetSubject
; Description ...:
; Syntax ........: _POP3_EML_GetSubject($sEML_Content[, $bDecodeQP = True])
; Parameters ....: $sEML_Content        - A string value.
;                  $bDecodeQP           - [optional] A binary value. Default is True.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_GetSubject($sEML_Content, $bDecodeQP = True)
    Local $aSubject = StringRegExp($sEML_Content, '(?i)(?:\A|\R)Subject: (\V+)', 3)
    If UBound($aSubject) Then
        Return SetError(0, 0, $bDecodeQP ? _QuotedPrintable_DecodeEncodedWord($aSubject[0]) : $aSubject[0])
    EndIf
    Return SetError(1, 0, '')
EndFunc   ;==>_POP3_EML_GetSubject

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_GetThreadTopic
; Description ...:
; Syntax ........: _POP3_EML_GetThreadTopic($sEML_Content[, $bDecodeQP = True])
; Parameters ....: $sEML_Content        - A string value.
;                  $bDecodeQP           - [optional] A binary value. Default is True.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_GetThreadTopic($sEML_Content, $bDecodeQP = True)
    Local $aTopic = StringRegExp($sEML_Content, '(?i)(?:\A|\R)Thread-Topic: (\V+)', 3)
    If UBound($aTopic) Then
        Return SetError(0, 0, $bDecodeQP ? _QuotedPrintable_DecodeEncodedWord($aTopic[0]) : $aTopic[0])
    EndIf
    Return SetError(1, 0, '')
EndFunc   ;==>_POP3_EML_GetThreadTopic

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_GetFrom
; Description ...:
; Syntax ........: _POP3_EML_GetFrom($sEML_Content[, $bDecodeQP = True])
; Parameters ....: $sEML_Content        - A string value.
;                  $bDecodeQP           - [optional] A binary value. Default is True.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_GetFrom($sEML_Content, $bDecodeQP = True)
    Local $aFrom = StringRegExp($sEML_Content, '(?i)(?:\A|\R)From: (\V+)', 3)
    If UBound($aFrom) Then
        Return SetError(0, 0, $bDecodeQP ? _QuotedPrintable_DecodeEncodedWord($aFrom[0]) : $aFrom[0])
    EndIf
    Return SetError(1, 0, '')
EndFunc   ;==>_POP3_EML_GetFrom

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_GetTo
; Description ...:
; Syntax ........: _POP3_EML_GetTo($sEML_Content[, $bDecodeQP = True])
; Parameters ....: $sEML_Content        - A string value.
;                  $bDecodeQP           - [optional] A binary value. Default is True.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_GetTo($sEML_Content, $bDecodeQP = True)
    Local $aTo = StringRegExp($sEML_Content, '(?i)(?:\A|\R)To: (\V+)', 3)
    If UBound($aTo) Then
        Return SetError(0, 0, $bDecodeQP ? _QuotedPrintable_DecodeEncodedWord($aTo[0]) : $aTo[0])
    EndIf
    Return SetError(1, 0, '')
EndFunc   ;==>_POP3_EML_GetTo

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_EML_Parser
; Description ...:
; Syntax ........: _POP3_EML_Parser ($sEML_Contents)
; Parameters ....: $sEML_Contents           - A string value.
; Return values .:
;                 It returns an Array where saved:
;                 In the 1st line - Sender's name
;                 In the 2nd line - Sender's address
;                 In the 3rd line - Recipient name
;                 In the 4th line - Recipient address
;                 In the 5th line - Subject
;                 In the 6th line - Charset
;                 In the 7th line - Message body
;                 In the 8th line - Attachment's name (if exists)
;                 In the 9th line - Attachment's body (if exists)
;                 In the next pairs of lines - names and bodies of the other attachments (if exist)
; Author ........: Tipulatoid, MrCreatoR
; Modified ......: mLipok
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/22838-pop3-udf-according-to-the-1939-rfc/#entry596715
; Example .......: No
; ===============================================================================================================================
Func _POP3_EML_Parser($sEML_Contents)
    Local $aLetter[1]
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^From: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^To: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^Subject: +(.*)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?i)charset="?(.*?)(?:"|\r\n)', 1), $aLetter)

    Local $aSplit = StringSplit($sEML_Contents, @CRLF, 1)
    Local $iFirstBoundaryString = _ArraySearch($aSplit, "boundary=", 0, 0, 0, 1)
    Local $iBoundary = $aSplit[$iFirstBoundaryString]
    Local $iBoundary_StartPos = StringInStr($iBoundary, '"')
    Local $iBoundary_EndPos = StringInStr($iBoundary, '"', 0, 2)
    Local $boundary = StringMid($iBoundary, $iBoundary_StartPos + 1, $iBoundary_EndPos - $iBoundary_StartPos - 1)
    Local $boundary1 = _ArraySearch($aSplit, $boundary, $iFirstBoundaryString + 1, 0, 1, 1)
    Local $boundary2 = _ArraySearch($aSplit, $boundary, $boundary1 + 1, 0, 1, 1)
    Local $sMessage = ""
    Local $bWrite = False
    For $i = $boundary1 To $boundary2 - 1
        If $aSplit[$i] = "" Then $bWrite = True
        If $bWrite = True Then $sMessage &= $aSplit[$i] & @CRLF
    Next
    __POP3_EML_Parser_AddToLetterArray($sMessage, $aLetter)

    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?ims)filename="?(.*?)(?:"|\r).*?\n\r\n(.*?)\r\n^-+', 3), $aLetter)

    Return $aLetter
EndFunc   ;==>_POP3_EML_Parser

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name ..........: __POP3_EML_Parser_AddToLetterArray
; Description ...:
; Syntax ........: __POP3_EML_Parser_AddToLetterArray($aContents, Byref $afLetter)
; Parameters ....: $aContents           - An array of unknowns.
;                  $afLetter            - [in/out] An array of booleans.
; Return values .: None
; Author ........: Tipulatoid, MrCreatoR
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/22838-pop3-udf-according-to-the-1939-rfc/#entry596715
; Example .......: No
; ===============================================================================================================================
Func __POP3_EML_Parser_AddToLetterArray($aContents, ByRef $afLetter)
    If IsArray($aContents) Then
        For $i_ID = 0 To UBound($aContents) - 1
            _ArrayAdd($afLetter, $aContents[$i_ID])
        Next
    Else
        _ArrayAdd($afLetter, $aContents)
    EndIf
    ; Return $afLetter
EndFunc   ;==>__POP3_EML_Parser_AddToLetterArray

#EndRegion _POP3_Ex.au3 - _EML_ Functions

#Region _POP3_Ex.au3 - ConosoleDebugingSystem
Func _POP3_ConsoleDebugError($sText)
    If _POP3_ConsoleDebugSatus() Then
        ConsoleWriteError($sText & @CRLF)
    EndIf
EndFunc   ;==>_POP3_ConsoleDebugError

Func _POP3_ConsoleDebug($sText)
    If _POP3_ConsoleDebugSatus() Then
        ConsoleWrite($sText & @CRLF)
    EndIf
EndFunc   ;==>_POP3_ConsoleDebug

; #FUNCTION# ====================================================================================================================
; Name ..........: _POP3_ConsoleDebugSatus
; Description ...: Set/Check POP3 ConsoleDebugingSystem
; Syntax ........: _POP3_ConsoleDebugSatus([$bDebug = Default])
; Parameters ....: $bDebug              - [optional] A binary value. Default is Default = do not change nothing just return Current status.
; Return values .: Status, current or just set
; Author ........: mLipok
; Modified ......:
; Remarks .......: Default Status is False = POP3 ConsoleDebugingSystem is Disabled
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _POP3_ConsoleDebugSatus($bDebug = Default)
    Local Static $bDebugStatic = False
    If $bDebug <> Default Then
        If $bDebug = True Then
            $bDebugStatic = True
        Else
            $bDebugStatic = False
        EndIf
    EndIf
    Return $bDebugStatic
EndFunc   ;==>_POP3_ConsoleDebugSatus
#EndRegion _POP3_Ex.au3 - ConosoleDebugingSystem

#Region _POP3_Ex.au3 - #INTERNAL_USE_ONLY#
; #INTERNAL_USE_ONLY# ==========================================================
; Name ..........: __POP3_Cmd
; Description ...:
; Syntax ........: __POP3_Cmd($sMSg)
; Parameter(s): .: $sMSg -
; Return Value ..: Success - string
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Thu Jan 14 17:07:08 CET 2010
; ==============================================================================
Func __POP3_Cmd($sMSg)
    If _POP3_ConsoleDebugSatus() Then _POP3_ConsoleDebug(">: " & $sMSg & @CRLF)
    TCPSend($g__iPOP3_SOCKET, $sMSg & @CRLF)
    If @error Then Return SetError($POP3_ERROR_USER_REFUSED, 0, 0)
    Local $sRet = __POP3_WaitForOK()
    If @error Then Return SetError($POP3_ERROR_NO_OK_RESPONSE, 0, 0)
    Return $sRet
EndFunc   ;==>__POP3_Cmd

; #INTERNAL_USE_ONLY# ==========================================================
; Name ..........: __POP3_WaitForOK
; Description ...: Returns the server response if it starts with "+OK"
; Syntax ........: __POP3_WaitForOK()
; Parameter(s): .: -
; Return Value ..: Success - string
; Failure - ""
; @ERROR -
; Author(s) .....: Luc HENNINOT, Thorsten Willert
; Date ..........: Thu Jan 14 11:50:34 CET 2010
; ==============================================================================
Func __POP3_WaitForOK()
    ; Wait for server response.
    Local $sRet
    Local $hTimer = TimerInit()
    While TimerDiff($hTimer) < _POP3_ServerResponseTimeOut()
        $sRet = __POP3_WaitTcpResponse()
        If Not @error And StringRegExp($sRet, '\+OK') Then Return StringRegExpReplace($sRet, '\+OK\s?', "")
        If StringRegExp($sRet, '\-ERR\s?') Then Return SetError($POP3_ERROR_ERR_RESPONSE, 0, "")
        Sleep(100)
    WEnd

    Return SetError($POP3_ERROR_SERVER_RESPONSE_TIMEOUT, 0, "")
EndFunc   ;==>__POP3_WaitForOK

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name ..........: __POP3_WaitTcpResponse
; Description ...: Returns the server response
; Syntax ........: __POP3_WaitTcpResponse()
; Return values .:
;                 Success - string
;                 Failure - 0
; Author ........: Luc HENNINOT
; Modified ......: Thorsten Willert, mLipok
; Remarks .......: Timeout to 60 s, should be enough in most cases. Change it if needed by using _POP3_ServerResponseTimeOut().
; Related .......: _POP3_ServerResponseTimeOut()
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func __POP3_WaitTcpResponse()
    Local $sRet = ""
    Local $hTimer = TimerInit()
    While TimerDiff($hTimer) < _POP3_ServerResponseTimeOut()
        $sRet = TCPRecv($g__iPOP3_SOCKET, 512)
        If _POP3_ConsoleDebugSatus() And $sRet Then _POP3_ConsoleDebug("<: " & $sRet)
        If $sRet <> "" Then Return $sRet
        Sleep(100)
    WEnd

    Return SetError($POP3_ERROR_TCPRECV_TIMEOUT, 0, 0)
EndFunc   ;==>__POP3_WaitTcpResponse

#EndRegion _POP3_Ex.au3 - #INTERNAL_USE_ONLY#

Quoted-printable.au3:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include-once
; #INDEX# =======================================================================================================================
; Title .........: UDF to Decode Word Encoded with Quoted Printable
; AutoIt Version : 3.3.10.2++
; Language ......: English
; Description ...:
; Author(s) .....: Prog@ndy
; Modified ......: mLipok
; ===============================================================================================================================
#cs
    Author original post
    https://autoit.de/index.php/Thread/11350-UTF8-Sting-Convertieren/?postID=87721#post87721

    Quoted-Printable
    http://tools.ietf.org/html/rfc2045#section-6.7
    https://www.ietf.org/rfc/rfc2045.txt
#ce

;~ _QuotedPrintable_Example()

Func _QuotedPrintable_Example()
    Local $sTestString = ''
;~ https://autoit.de/index.php/Thread/11350-UTF8-Sting-Convertieren/?postID=87721#post87721
;~ $sTestString = "=?utf-8?b?QmFja3VwIEV4ZWMtTWVsZHVuZzogQXVmdHJhZyBlcmZvbGdyZWljaA==?="
    $sTestString = "=?iso-8859-2?Q?3%_na_Otwartym_Koncie_Oszcz=EAdno=B6ciowym?="
    MsgBox(0, '', _QuotedPrintable_DecodeEncodedWord($sTestString))
    MsgBox(0, '', _QuotedPrintable_DecodeEncodedWord("Subject: =?iso-8859-1?Q?=A1Hola,_se=F1or!?="))
EndFunc   ;==>_QuotedPrintable_Example

; #FUNCTION# ====================================================================================================================
; Name ..........: _QuotedPrintable_GetCodepage
; Description ...:
; Syntax ........: _QuotedPrintable_GetCodepage($charset)
; Parameters ....: $charset             - An unknown value.
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QuotedPrintable_GetCodepage($charset)
    Local Const $PATH = "HKEY_CLASSES_ROOT\MIME\Database\Charset\"
    Local $alias
    While 1
        $alias = RegRead($PATH & $charset, "AliasForCharset")
        If @error Then ExitLoop
        $charset = $alias
    WEnd
    Local $result = RegRead($PATH & $charset, "InternetEncoding")
    Return SetError(@error, @extended, $result)
EndFunc   ;==>_QuotedPrintable_GetCodepage

; #FUNCTION# ====================================================================================================================
; Name ..........: _QuotedPrintable_MultiByteToWideChar
; Description ...:
; Syntax ........: _QuotedPrintable_MultiByteToWideChar($CodePage, $dwFlags, $lpMultiByteStr, $cbMultiByte, $lpWideCharStr,
;                  $cchWideChar)
; Parameters ....: $CodePage            - An unknown value.
;                  $dwFlags             - An unknown value.
;                  $lpMultiByteStr      - An unknown value.
;                  $cbMultiByte         - An unknown value.
;                  $lpWideCharStr       - An unknown value.
;                  $cchWideChar         - An unknown value.
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QuotedPrintable_MultiByteToWideChar($CodePage, $dwFlags, $lpMultiByteStr, $cbMultiByte, $lpWideCharStr, $cchWideChar)
    Local $TypeMBStr = "str"
    If IsPtr($lpMultiByteStr) Then $TypeMBStr = "ptr"
    Local $aResult = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", "UINT", $CodePage, "DWORD", $dwFlags, _
            $TypeMBStr, $lpMultiByteStr, "int", $cbMultiByte, "ptr", $lpWideCharStr, "int", $cchWideChar)
    If @error Then Return SetError(@error, 0, 0)
    Return $aResult[0]
EndFunc   ;==>_QuotedPrintable_MultiByteToWideChar

; #FUNCTION# ====================================================================================================================
; Name ..........: _QuotedPrintable_TranslateString
; Description ...:
; Syntax ........: _QuotedPrintable_TranslateString($String, $CodePage)
; Parameters ....: $String              - An unknown value.
;                  $CodePage            - An unknown value.
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QuotedPrintable_TranslateString($String, $CodePage)
    SetError(0)
    If Not (IsInt($CodePage) And $CodePage > 0) Then $CodePage = _QuotedPrintable_GetCodepage($CodePage)
    If @error Or $CodePage = 0 Then Return SetError(1, 0, "")
    Local $Length = _QuotedPrintable_MultiByteToWideChar($CodePage, 0, $String, StringLen($String), 0, 0)
    Local $Buffer = DllStructCreate("wchar[" & $Length + 1 & "]")
    If Not _QuotedPrintable_MultiByteToWideChar($CodePage, 0, $String, StringLen($String), DllStructGetPtr($Buffer), $Length) Then
        Return SetError(2, 0, "")
    EndIf
    Return DllStructGetData($Buffer, 1)
EndFunc   ;==>_QuotedPrintable_TranslateString

; #FUNCTION# ====================================================================================================================
; Name ..........: _QuotedPrintable_Base64Decode
; Description ...:
; Syntax ........: _QuotedPrintable_Base64Decode($s)
; Parameters ....: $s                   - A string value.
; Return values .: None
; Author ........: Eddy
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QuotedPrintable_Base64Decode($s)
    Local $key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', _
            $t = '', $p = -8, $a = 0, $c, $d, $len = StringLen($s)
    For $i = 1 To $len
        $c = StringInStr($key, StringMid($s, $i, 1), 1) - 1
        If $c < 0 Then ContinueLoop
        $a = BitOR(BitShift($a, -6), BitAND($c, 63))
        $p = $p + 6
        If $p >= 0 Then
            $d = BitAND(BitShift($a, $p), 255)
            If $c <> 64 Then $t = $t & Chr($d)
            $a = BitAND($a, 63)
            $p = $p - 8
        EndIf
    Next
    Return $t
EndFunc   ;==>_QuotedPrintable_Base64Decode

; #FUNCTION# ====================================================================================================================
; Name ..........: _QuotedPrintable_Decode
; Description ...:
; Syntax ........: _QuotedPrintable_Decode($s[, $IsQ = False])
; Parameters ....: $s                   - A string value.
;                  $IsQ                 - [optional] An unknown value. Default is False.
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QuotedPrintable_Decode($s, $IsQ = False)
    If $IsQ Then $s = StringReplace($s, "_", " ")
    $s = StringSplit($s, "=")
    Local $result = $s[1]
    For $i = 2 To $s[0]
        $result &= Chr(Dec(StringLeft($s[$i], 2))) & StringTrimLeft($s[$i], 2)
    Next
    Return $result
EndFunc   ;==>_QuotedPrintable_Decode

; #FUNCTION# ====================================================================================================================
; Name ..........: _QuotedPrintable_DecodeEncodedWord
; Description ...:
; Syntax ........: _QuotedPrintable_DecodeEncodedWord($theString)
; Parameters ....: $theString           - A dll struct value.
; Return values .: None
; Author ........: Prog@ndy
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _QuotedPrintable_DecodeEncodedWord($theString)
    Local $EncodedChunks = StringRegExp($theString, "=\?(.+?)\?(.)\?(.*?)\?=", 4)
    If Not @error Then
        Local $parts
        For $Index = 0 To UBound($EncodedChunks) - 1
            $parts = $EncodedChunks[$Index]
            Switch $parts[2]
                Case "B", "b"
                    $parts[3] = _QuotedPrintable_Base64Decode($parts[3])
                Case "Q", "q"
                    $parts[3] = _QuotedPrintable_Decode($parts[3], True)
            EndSwitch
            $parts[3] = _QuotedPrintable_TranslateString($parts[3], $parts[1])
            $theString = StringReplace($theString, $parts[0], $parts[3])
        Next
    EndIf
    Return $theString
EndFunc   ;==>_QuotedPrintable_DecodeEncodedWord

Cheers

mLipok

 

EDIT: Topic title change, and Script bug correction

EDIT2: Script correction #CS #CE >> #cs #ce    -- changed for correct display by GESHi

_POP3_Ex.ZIP

 

 

 

 

 

 

Edited by mLipok
+screenshot

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

8 downloads .. no comments ?
 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

8 downloads .. no comments ?

You have 2753 posts so far and you really ask that question? And further after 8! downloads?  :shocked:

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Thanks for your comment.
I was thinking about more constructive comments.
 
But this was also instructive.
 
I'll try to be more patient.
 
mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Thanks for the library it was a great help. I was able to successfully implement it in a small program with some minor modifications.

I have the same issue as has been identified but apparently not resolved where the Parser fails with an array violation.

I found the issue to be the emails that I am reading do not have 'boundary=' lines so the _ArraySearch function returns a -1 which is causes the failure as the array reference.

For my purposes the content of the email follows the MIME-version: header and the content is simple unformatted text. I decided to deliver the content in my array as one element per line excluding the blank lines. I substituted the following code: 

Func _POP3_EML_Parser($sEML_Contents)
    Local $aLetter[1]
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^From: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^To: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^Subject: +(.*)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?i)charset="?(.*?)(?:"|\r\n)', 1), $aLetter)
    Local $aSplit = StringSplit($sEML_Contents, @CRLF, 1)
    Local $boundary1 = _ArraySearch($aSplit, "MIME-Version:", 0, 0, 0, 1) + 1
    Local $boundary2 = UBound($aSplit)
    Local $sMessage = ""
    Local $bWrite = False
    For $i = $boundary1 To $boundary2 - 1
            If $aSplit[$i] <> "" Then __POP3_EML_Parser_AddToLetterArray($aSplit[$i], $aLetter)
    Next
    Return $aLetter
EndFunc   ;==>_POP3_EML_Parser

I didn't research very far into the formatting mysteries that appear to be happening. I just made some code that worked for this one need. If I have some time I may come back to look at this.
 

Share this post


Link to post
Share on other sites

Sorry for late repy:

http://www.ietf.org/rfc/rfc1939.txt

Quote

   When the client issues the QUIT command from the TRANSACTION state,
   the POP3 session enters the UPDATE state.  (Note that if the client
   issues the QUIT command from the AUTHORIZATION state, the POP3
   session terminates but does NOT enter the UPDATE state.)

   If a session terminates for some reason other than a client-issued
   QUIT command, the POP3 session does NOT enter the UPDATE state and
   MUST not remove any messages from the maildrop.

      QUIT

         Arguments: none

         Restrictions: none

         Discussion:
             The POP3 server removes all messages marked as deleted
             from the maildrop and replies as to the status of this
             operation.  If there is an error, such as a resource
             shortage, encountered while removing messages, the
             maildrop may result in having some or none of the messages
             marked as deleted be removed.  In no case may the server
             remove any messages not marked as deleted.

             Whether the removal was successful or not, the server
             then releases any exclusive-access lock on the maildrop
             and closes the TCP connection.

 

but I see other problem .... working on.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites
Quote

9. POP3 Command Summary

      Minimal POP3 Commands:

         USER name               valid in the AUTHORIZATION state
         PASS string
         QUIT

         STAT                    valid in the TRANSACTION state
         LIST [msg]
         RETR msg
         DELE msg
         NOOP
         RSET
         QUIT

This should work:

#include <array.au3>
#include <FileConstants.au3>
#include "_POP3_Ex.au3"
#include "Quoted-printable.au3"

Global $sPOP3_MyPopServer = "XXXXX"
Global $sPOP3_MyLogin = "XXXXX"
Global $sPOP3_MyPasswd = "XXXXX"


;~ _POP3_ServerResponseTimeOut(60000)
_POP3_ConsoleDebugSatus(True)

_POP3_ServerConnect($sPOP3_MyPopServer)
If @error Then MsgBox($MB_ICONERROR, 'Connect', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

_POP3_ServerLogIn($sPOP3_MyLogin, $sPOP3_MyPasswd)
If @error Then MsgBox($MB_ICONERROR, 'LogIn','@error = ' & @error & @CRLF & '@extended = ' & @extended)


_POP3_RFC_LIST(1)
_POP3_RFC_RETR(1)
_POP3_EML_SaveToFile(1, @ScriptDir & '\Test_'& @YEAR & @MON & @MDAY & '_' & @HOUR&@MIN & @SEC &'.eml')
If @error Then MsgBox($MB_ICONERROR, 'SAVE', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

_POP3_RFC_DELE(1)
If @error Then MsgBox($MB_ICONERROR, 'DELE', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

new version:

Quote

    2016/05/04 ver. 2.0.1
    .    Renamed:     UDF:    _POP3_Ex.au3 >> POP3.au3 - mLipok
    .    Renamed:     Var:    $g__iPOP3_SOCKET >> $__g_iPOP3_SOCKET - mLipok
    .    Renamed:     Var:    $POP3_OK >> $POP3_REGEXP_OK - mLipok
    .    New:         Var:    $POP3_REGEXP_ERR - mLipok
    .    New:         Var:    $POP3_REGEXP_PASS - mLipok
    .    New:         Var:    $POP3_CALLBACK_COMMAND - mLipok
    .    New:         Var:    $POP3_CALLBACK_STATUS - mLipok
    .    Renamed:     Enums:     $POP3_ERROR_* >> $POP3_ERR_* - mLipok
    .    Renamed:     Enum:     $POP3_ERR_OK >> $POP3_ERR_SUCCESS - mLipok
    .    Renamed:     Enum:     $POP3_ERR >> $POP3_ERR_GENERAL - mLipok
    .    Renamed:     Enum:     $POP3_ERR_SERVER_RESPONSE_TIMEOUT >> $POP3_ERR_TIMEOUT - mLipok
    .    Renamed:     Enum:     $POP3_ERR_TCPRECV_TIMEOUT >> $POP3_ERR_TIMEOUT - mLipok
    .    Renamed:     Enum:     $POP3_ERR_TCPCONNECT_FAILED >> $POP3_ERR_TCPCONNECT - mLipok
    .    New:         Enum:     $POP3_ERR_TCPSTARTUP - mLipok
    .    New:         Enum:     $POP3_ERR_SSL - mLipok
    .    New:         Enum:     $POP3_EXT_CONNECTED - mLipok
    .    New:         Enum:     $POP3_ERR_TCPRECV - mLipok
    .    New:        Func:     _POP3_UDFVersion - mLipok
    .    Removed:     Enum:     $POP3_ERR_ALREADY_CONNECTED --> Check for $POP3_EXT_CONNECTED - mLipok
    .    Removed:     Enum:     $POP3_ERR_NO_TCP_RESPONSE - is no longer used - mLipok
    .    Removed:     Enum:     $POP3_ERR_NO_OK_RESPONSE - is no longer used - mLipok
    .    Renamed:     Func:    __POP3_Cmd >> __POP3_SendCommand - mLipok
    .    Renamed:     Func:    _POP3_ConsoleDebug >> _POP3_Callback - mLipok
    .    Renamed:     Func:    _POP3_ConsoleError >> _POP3_CallbackError - mLipok
    .    Removed:     Func:    _POP3_CallbackSatus --> _POP3_Callback(FirstClassFunction) - mLipok
    .    Renamed:     Func:    _POP3_ServerIsConnected >> _POP3_IsConnected - mLipok
    .    Renamed:     Func:    _POP3_ServerIsAuth >> _POP3_IsAuthorized - mLipok
    .    Removed:    Func:     _POP3_CallbackFunction - mLipok
    .    Refactored: Func:    _POP3_IsConnected - mLipok
    .    Refactored: Func:    _POP3_IsAuthorized - mLipok
    .    Refactored: Func:     _POP3_RFC_... Functions: Finally correctly reporting: $POP3_ERR_**_REFUSED - mLipok
    .    Refactored: Func:     All faunction - mLipok
    .                If _POP3_IsAuthorized() Then  >>> checking @error
    .    Refactored: Func:    @error handling almost all functions - mLipok
    .                If @error Then Return SetError(@error, @extended, .......
    .    Refactored:    Var:    Magic Number replaced with Const/Enums - mLipok
 

 

Download link.

Regards,
mLipok

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

BEWARE: do not use Magic Number in @error checking.
Name and order can be changed in the future - for this reason I recommend using  $POP3_ERR_*  enumerated constants.

 


Some reference documentation:  https://tools.ietf.org/html/rfc1939

 


Example:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#include <array.au3>
#include <FileConstants.au3>
#include "POP3.au3"
#include "Quoted-printable.au3"

ConsoleWrite('POP3.au3 UDF v.' & _POP3_UDFVersion() & @CRLF)
ConsoleWrite('@AutoItVersion=' & @AutoItVersion & @CRLF)

Global $sPOP3_MyPopServer = "xxxx"
Global $sPOP3_MyLogin = "xxxx"
Global $sPOP3_MyPasswd = "xxxx"

;~ _POP3_ServerResponseTimeOut(60000)
_POP3_Callback(_MyPOP3_Callback)
_POP3_CallbackError(_MyPOP3_CallbackError)

_Example_1()
If @error Then MsgBox($MB_ICONERROR, '_Example_1', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

_Example_2_UIDL()
If @error Then MsgBox($MB_ICONERROR, '_Example_1', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

Func _Example_1()
    _POP3_ServerConnect($sPOP3_MyPopServer)
    If @error Then Return SetError(@error, @extended, '')

    _POP3_ServerLogIn($sPOP3_MyLogin, $sPOP3_MyPasswd)
    If @error Then Return SetError(@error, @extended, '')

    _POP3_RFC_LIST(1)
    If @error Then Return SetError(@error, @extended, '')

    Local $sEMLFile = @ScriptDir & '\Test_' & @YEAR & @MON & @MDAY & '_' & @HOUR & @MIN & @SEC & '.eml'
    _POP3_EML_SaveToFile(1, $sEMLFile)
    If @error Then Return SetError(@error, @extended, '')

;~  _POP3_RFC_DELE(1)
;~  If @error Then Return SetError(@error, @extended, '')

    _POP3_RFC_QUIT()
    If @error Then Return SetError(@error, @extended, '')

    _POP3_ServerDisconnect()
EndFunc   ;==>_Example_1

Func _Example_2_UIDL()
    _POP3_ServerConnect($sPOP3_MyPopServer)
    If @error Then Return SetError(@error, @extended, '')

    _POP3_ServerLogIn($sPOP3_MyLogin, $sPOP3_MyPasswd)
    If Not @error Then
        Local $aUIDL = _POP3_RFC_UIDL()
        If Not @error Then _ArrayDisplay($aUIDL, '_POP3_RFC_UIDL() Results')

        _POP3_RFC_QUIT()
    EndIf

    _POP3_ServerDisconnect()
EndFunc   ;==>_Example_2_UIDL

Func _MyPOP3_Callback($sText)
    ConsoleWrite($sText)
EndFunc   ;==>_MyPOP3_Callback

Func _MyPOP3_CallbackError($sText)
    ConsoleWrite('! ' & $sText)
EndFunc   ;==>_MyPOP3_CallbackError

 

POP3_v2.jpg.f349c1b3a1841cfc8782bdfdc720

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Many Thanks!

But i'm getting an error:

_POP3_ServerConnect: connecting to: xxx.xxxxx.com  - using port: 110
xxx.xxxxxx.com >> xx.xxx.xxx.xxx
! [ 10060 / 0 ]   _POP3_ServerConnect: Error: $POP3_ERR_TCPCONNECT

I think is not a problem with the port or server name because same values are working with two command line pop clients:

  1. popclient (very good)
  2. and a quiet old 'getmail for windows' (not the same as this other getmail that looks very proffesional but difficult to install on windows)

The hosting provider I am using is Dreamhost. I've tested changing server name for 'cluster name' as explained here:

But always the same error codes: 5, extended 10060

Tested in XP and Windows 10

 

Share this post


Link to post
Share on other sites

Maybe your server require some security like SSL or TLS ?

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Surprisingly, new test from the office pc (windows 7) and JUST WORKS!,

without any changes

_POP3_ServerConnect: connecting to: XXX.XXXXXX.com  - using port: 110
XXX.XXXXXXX.com >> XX.XXX.XXX.XXX
< S: +OK Dovecot ready.
> C: USER xxxxxxx@xxxxx.com
< S: +OK
> C: PASS XXXXXXXX
< S: +OK Logged in.

Maybe my tests from home were using some kind of less secure conexion that is rejected by DreamHost.

i was using low cost tech: and old xp laptop connected toa a quite old mobile phone (Android 2 i think) as modem (tethering)

not very releably ...

Many Thanks mLipok for alls your work in the forum

Share this post


Link to post
Share on other sites
On lunes, 26 de febrero de 2018 at 9:13 AM, robertocm said:

Maybe my tests from home were using some kind of less secure conexion that is rejected by DreamHost.

i was using low cost tech: and old xp laptop connected toa a quite old mobile phone (Android 2 i think) as modem (tethering)

Just to report that i've made a new test with the 'low cost tech' and WORKING! through stunnel

I've read this from hevoxer, 2012

Quote

It is easy to do that these functions to work with SSL. All we need is install stunnel.

He also explains very well how to install stunnel and configure it in this post, see his example of 'Configuration file for stunnel for POP3.'

Following this instructions i've edited the example stunnel.conf file in the config folder. All lines comented except:

; **************************************************************************
; * Service defaults may also be specified in individual service sections  *
; **************************************************************************
; Certificate/key is needed in server mode and optional in client mode

cert = stunnel.pem

;...

; Disable support for insecure SSLv2 protocol

options = NO_SSLv2

;...

; **************************************************************************
; * Service definitions (at least one service has to be defined)           *
; **************************************************************************

; ***************************************** Example TLS client mode services

; Example SSL client mode services

[pop3]
client = yes
;This means that stunnel works in client mode
accept = 127.0.0.1:110
;Port number on our machine on which stunnel will be listen to incoming non-ciphered connection. By default if POP3 is non secured 110 is the port on which it works. That could be any other free port.
connect = my.emailserver.com:995
;on this server and port, stunnel redirect connection incoming on localhost 110 but now it will be ssl secured. And that's it! CHANGE SERVER NAME TO YOUR OWN!!!

And finally, just changed a line in POP3_Example.au3:

;comented this
;Global $sPOP3_MyPopServer = "my.emailserver.com"
;replaced for this
Global $sPOP3_MyPopServer = "127.0.0.1"

And gets connection:

POP3.au3 UDF v.2.0.1
@AutoItVersion=3.3.14.2
! [ 9 / 0 ]   _POP3_IsConnected: $POP3_ERR_NOT_CONNECTED
_POP3_ServerConnect: connecting to: 127.0.0.1  - using port: 110
< S: +OK Dovecot ready.
> C: USER myusername@emailserver.com
< S: +OK
> C: PASS XXXXXXXX
< S: +OK Logged in.

 

Note: execute the stunnel installer from a path without spaces (the installer doesn't seems to like paths with spaces, at least in my case, i needed to move the installer to another path without spaces)

Edited by robertocm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By wysocki
      I have a smartphone and I use it to access my email. However, when composing an email on it I have a problem. My list of phone contacts on the phone is very different from my list of email contacts in my Thunderbird desktop app.  I use my Gmail address book to store primarily phone contacts, and I use Thunderbird for my list of email contacts. I wanted a way to get my Thunderbird contact list onto my smartphone to be able to compose emails to addresses in that list. Here's my solution.
      I wrote a script to export my Thunderbird Personal Address Book to a csv file. It then reads that file and re-writes it with html wrappers around the data to make it into a nicely formatted web page. It then uploads the htm file to my website. On my smartphone, I created a shortcut to the file's URL and whenever I click it, I get the list displayed. Each contact shows name and email address along with a COPY button that will put the address into the clipboard. Then in my email client, I can easily paste that address into it. Alternatively, clicking on the actual email link will open a new message dialog in your email client with that address already entered.
      To use the app, all you need to do is use Thunderbird and have a webserver available. You'll need to download the FTPEX.AU3 file from this website and make a few changes to some constants around line 17 for FTP login info, etc.
       
      pab2ftp.au3
    • By ozymandius257
      This is probably a very simple question (I hope!)
      I'm looking to use a UDF to access a SQL database, and have found ADO.au3, but I can't seem to work out how to use it.
      I've copied the files ado.au3 and ado_constants.au3 into the folder C:\Program Files (x86)\AutoIt3\Include, then opened SciTe and started a new project.
      But when I type #include<AD - I don't get offered ADO.au3.
      (I know I should be using the folder C:\Program Files (x86)\AutoIt3\UserInclude, but when it didn't work from there, I tried the above).
      What am I doing wrong?
       
    • By BetaLeaf
      What is Rollbar?
      Rollbar provides real-time error alerting & debugging tools for developers. Learn more about it at https://rollbar.com/product/
      Demo: https://rollbar.com/demo/demo/
      Screenshot:
      Instructions: (RollbarTest.au3)
      ; Include RollbarSDK #include "RollbarSDK.au3" ;Turns on ConsoleWrite debugging override. ;Global $Rollbar_Debug=False ; Initialize RollbarSDK with the project's API key. ; Parameters ....: $__Rollbar_sToken - [Required] Go to https://rollbar.com/<User>/<ProjectName>/settings/access_tokens/ for your project. Use the token for post_server_item. _Rollbar_Init("eaa8464a4082eeabd9454465b8f0c0af") ; Write code that causes an error you want to catch, then call ; _Rollbar_Send ; Parameters ....: $__Rollbar_sErrorLevel - [Required] Must be one of the following values: Debug, Info, Warning, Error, Critical. ; $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_Send("Debug", "This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_Send("Warning", "This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_Send("Error", "This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_Send("Critical", "This is an critical message. If you received this, you were successful!", "Critical Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!") ;No Message ; Rollbar_Send's helper functions ; Parameters ....: $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_SendDebug("This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_SendInfo("This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_SendWarning("This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_SendError("This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_SendCritical("This is an critical message. If you received this, you were successful!", "Critical Message") ; Usable Example Local $sImportantFile = "C:\NOTAREALFILE_1234554321.txt" Switch FileExists($sImportantFile) Case True MsgBox(0, "Example Script", "An important file was found. Continuing...") Case Else _Rollbar_SendCritical('An important file was missing. Halting... File: "' & $sImportantFile & '"', 'Important file "' & $sImportantFile & '" is missing.') EndSwitch Notes: Please comment your feedback, advice, & suggestions below. While this is only a proof of concept, I will expand its feature set for everyone to use. 
      Right now, it is fully functional but not tested in production.
       
       
      Changelog:
      RollbarSDK.au3
      RollbarTest.au3
      v0.2
       
      v0.1.1
       
    • By kurtykurtyboy
      GuiFlatButton is a UDF to easily create regular buttons with different colors for background, foreground, border, hover, focus, etc..
      This started as an effort to change the background color of a button and eventually grew into a full UDF.
      If you've looked around forums for changing button background colors, you have probably noticed that each proposed workaround has its own set of issues/side-effects. The answers usually circle back to 'use ownerdrawn buttons' and 'not worth it'. Well, now it is possible for anyone to easily create ownerdrawn buttons - totally worth it!
      Some issues with other workarounds such as drawing with GDI+ or using a colored label as a 'button':
      Not 'real' buttons so you lose built-in functionality that windows gives to buttons Messy / inefficient code in the main while loop to check for mouse position Slow to respond to click, paint, etc... Having to deal with GUIRegisterMsg messages Not straight-forward to implement GuiFlatButton is not a workaround; it is a technique to respond to Windows' built-in owner-drawn button events.
      With minimal effort, we can now create true simple colored buttons.
      The idea is to create an owner-drawn button using GUICtrlCreateButton then subclass the GUI and controls to handle the button-specific events to paint it however we want.
      This UDF magically does all of this for us! No need to worry about event handling or main while loop logic.
       
      How to use
      It couldn't be any easier! Simply create a new button using the familiar syntax. This creates an ownerdrawn button with default colors.
      $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) If you want to change the background and text colors:
      GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) Advanced Usage
      Set background/text/border all at once
      GuiFlatButton_SetColors(-1, 0x0000FF, 0xFFFFFF, 0x9999FF) Set ALL colors for ALL button states! (normal, focus, hover, selected)
      Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetColorsEx(-1, $aColorsEx) Set default colors to apply to any future buttons
      ;set colors GuiFlatButton_SetDefaultColors(0x0000FF, 0xFFFFFF, 0x9999FF) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Set ALL color defaults
      ;set colors Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40)  
      Available Functions
       
      Simple Example

      #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;GUI with one button Func Example() Local $hGUI, $mybutton1 $hGUI = GUICreate("GuiFlatButton Ex0", 275, 120) GUISetBkColor(0x333333) $idLabel = GUICtrlCreateLabel("Click the button", 10, 100, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) ;create new button then set the background and foreground colors $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $mybutton1 $i += 1 GUICtrlSetData($idLabel, $i) ConsoleWrite($i & @CRLF) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example
      Menu/Toolbar Example

      #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;Example GUI with toolbar Func Example() Local $hGUI, $idLabel, $aButtons, $iTbSize $hGUI = GUICreate("GuiFlatButton Ex2", 300, 200) GUISetBkColor(0x444444) $idLabel = GUICtrlCreateLabel("Click a button", 10, 180, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) $aButtons = createToolbar() $iTbSize = UBound($aButtons) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButtons[0] To $aButtons[$iTbSize - 1] ConsoleWrite("1") GUICtrlSetData($idLabel, GuiFlatButton_Read($iMsg)) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Func createToolbar() Local $aButtons[6] Local $bkColor = 0x777777 Local $textColor = 0xFFFFFF Local $borderColor = 0x999999 Local $aBtnClrs[12] = [0x777777, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x888888, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x999999, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x666666, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT] For $i = 0 To UBound($aButtons) - 1 $aButtons[$i] = GuiFlatButton_Create("B" & $i, $i * 50, 0, 50, 17) GuiFlatButton_SetColorsEx($aButtons[$i], $aBtnClrs) Next Return $aButtons EndFunc ;==>createToolbar  
      Icon Example
      You can even easily add icons to your buttons -- just create a new button and send it an icon!

      #include <GDIPlus.au3> #include "GuiFlatButton.au3" Example() ;buttons with Icon images Func Example() ;get images for demonstration _GDIPlus_Startup() ;initialize GDI+ Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 258, 24, 24) ;extract the 'Save' icon Local $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) ;Create Bitmap from Icon (for demonstration) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap _GDIPlus_Shutdown() ;done with GDI+ Local $hGUI = GUICreate("GuiFlatButton Ex5", 255, 400) GUISetBkColor(0xEEEEEE) ;set default colors of future buttons Local $aColorsEx = _ [0xE2E5E8, 0X000000, 0x888888, _ ; normal : Background, Text, Border 0xE2E5E8, 0X000000, 0x333333, _ ; focus : Background, Text, Border 0xE8E8E8, 0X000000, 0x666666, _ ; hover : Background, Text, Border 0xDDDDDD, 0X000000, 0xAAAAAA] ; selected : Background, Text, Border GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;normal button with icon $label1 = GUICtrlCreateLabel( "$BS_TOOLBUTTON -->", 5, 10) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Local $mybutton1 = GuiFlatButton_Create("Save", 130, 5, 50, 48, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybutton1), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top Local $mybuttonT = GuiFlatButton_Create("Top", 5, 65, 120, 55, $BS_TOP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonT), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-left Local $mybuttonTL = GuiFlatButton_Create("Top-Left", 5, 125, 120, 55, BITOR($BS_TOP, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-right Local $mybuttonTR = GuiFlatButton_Create("Top-Right", 5, 185, 120, 55, BITOR($BS_TOP, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align left Local $mybuttonL = GuiFlatButton_Create("Left", 5, 245, 120, 55, $BS_LEFT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom Local $mybuttonB = GuiFlatButton_Create("Bottom", 130, 65, 120, 55, $BS_BOTTOM) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonB), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-left Local $mybuttonBL = GuiFlatButton_Create("Bottom-Left", 130, 125, 120, 55, BITOR($BS_BOTTOM, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-right Local $mybuttonBR = GuiFlatButton_Create("Bottom-Right", 130, 185, 120, 55, BITOR($BS_BOTTOM, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align right Local $mybuttonR = GuiFlatButton_Create("Right", 130, 245, 120, 55, $BS_RIGHT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) GuiFlatButton_SetState($mybuttonR, $GUI_DISABLE ) ;disabled Local $mybuttonDisable = GuiFlatButton_Create("Disabled", 130, 310, 120, 55, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonDisable), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GuiFlatButton_SetState($mybuttonDisable, $GUI_DISABLE ) ;clean up! _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DeleteObject( $hHBitmap ) GUISetState(@SW_SHOW, $hGUI) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example  
      I'm sure there are some use-cases I've forgotten, so feedback is welcome!
       
      Download the UDF and several more examples: GuiFlatButton_20190414.zip
      Update 2019-04-14
      Fixed bug, not showing pressed down state when clicking rapidly
      Added Icon/Bitmap support!
      Added function GuiFlatButton_SetPos to change the position and/or size of a button
      Update 2019-02-09
      Added 2 new functions to set the button colors globally for all future buttons.
      GuiFlatButton_SetDefaultColors 
      GuiFlatButton_SetDefaultColorsEx

      Credits to:
      Melba23 (UDF template)
      LarsJ (general subclassing code)
      4ggr35510n (TrackMouseEvent example)
      binhnx (disable dragging with $WS_EX_CONTROLPARENT)
      GUIRegisterMsg in AutoIt Help (owner-draw button example)
      funkey (_WinAPI_DrawState example)
    • By MFrancisca
      Hello! 
      I've been checking the logging UDFs in the wiki, mostly Log4a and Loga and I wanted to ask which one would you recommend for a script that will be executed remotely through PSExec. My main question is where the logs are located in that situation and if I can change that location to a custom one., because I need to retrieve them at the end of execution.
      So in a rough description the process is
      Open PSExec
      Send compiled AutoIT script to remote machine
      Execute script
      Copy logs from the remote to the local machine.
       
      Any opinions? 
×
×
  • Create New...