Jump to content

_POP3.au3 (V1.03)


Stilgar
 Share

Recommended Posts

Here's an updated version of this:

POP3-UDF

(array.au3 are not used anymore, better return codes, new functions, optimized code, added comments)

Many thanks to the original author Luc HENNINOT!

_POP3.au3

Current functions:

- _POP3Info (new)

- _POP3Connect (new: with "automatic" mode - tries to find the pop3-server by your email adress)

- _POP3Dele

- _POP3Disconnect

- _POP3List (new: returns an 2D-array)

- _POP3Noop

- _POP3Quit

- _POP3Retr

- _POP3Rset

- _POP3Stat

- _POP3MsgCnt (new)

- _POP3Top

- _POP3Uidl (new: returns an 2D-array)

- __POP3Cmd (new internal function)

Example:

If _POP3Connect("AnnExampleUser@freenet.de", "0815") Then
    $a = _POP3Info()
    _ArrayDisplay($a)
    _POP3Quit()
    _POP3Disconnect()
EndIf

The UDF:

_POP3.au3

Link to comment
Share on other sites

Can you give a list of compatible email address type, because after some tries it give :

with one :

_POP3Connect: Error: Can't find POP3-server.

+>10:12:11 AutoIT3.exe ended.rc:0

or

_POP3Connect: connecting to: (pop3.live.com) 65.55.32.247:110

+>10:17:08 AutoIT3.exe ended.rc:0

with an other :

_POP3Connect: connecting to: (pop.gmail.com) 74.125.43.109:110

+>10:23:14 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 64.895

Like you can see, script ends silently with no error message...

Only one works : pop3.free.fr ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Can you give a list of compatible email address type, because after some tries it give :

with one :

_POP3Connect: Error: Can't find POP3-server.

+>10:12:11 AutoIT3.exe ended.rc:0

or

_POP3Connect: connecting to: (pop3.live.com) 65.55.32.247:110

+>10:17:08 AutoIT3.exe ended.rc:0

with an other :

_POP3Connect: connecting to: (pop.gmail.com) 74.125.43.109:110

+>10:23:14 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 64.895

Like you can see, script ends silently with no error message...

Only one works : pop3.free.fr ! Posted Image

Hello,

the messages looks like two of them seems to work.

How looks the rest of your script?

"Compatible" addresses are depeding on your user-name.

E.g. if you are using a email-address "example@gmx.de" and you are call _POP3Connect like that:

_POP3Connect("example@foo.bat", "0815")

then the function tries to ping the following pop3-servers:

pop.foo.bar

pop3.foo.bar

pop.foo.com

pop3.foo.com

if this fails the message

_POP3Connect: Error: Can't find POP3-server

appears.

But you can call it with the POP3-server, too e.g.:

_POP3Connect("example@foo.bar", "0815", "pop3.foo.bar")
Edited by Stilgar
Link to comment
Share on other sites

I try like this

#include <_POP3.au3>

If _POP3Connect ( "*********@live.fr", "********", "pop3.live.com" ) Then
    $a = _POP3Info()
    _ArrayDisplay($a)
    $b = _POP3List ( )
    _ArrayDisplay ( $b )
    _POP3Quit()
    _POP3Disconnect()
EndIf

If _POP3Connect ( "**********@gmail.com", "**********", "pop.gmail.com" ) Then
    $a = _POP3Info()
    _ArrayDisplay($a)
    $b = _POP3List ( )
    _ArrayDisplay ( $b )
    _POP3Quit()
    _POP3Disconnect()
EndIf

but unsucessfully...

Edit : my gmail account is actived for pop.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • 1 month later...

How can i modify this exemple found with the first _POP3.au3 UDF ?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <array.au3>
#include <_pop3.au3>
#include <Constants.au3>
;#NoTrayIcon

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$settingsitem   = TrayCreateMenu("Settings")
$displayitem    = TrayCreateItem("Display", $settingsitem)
$printeritem    = TrayCreateItem("Printer", $settingsitem)
TrayCreateItem("")
$aboutitem      = TrayCreateItem("About")
TrayCreateItem("")
$exititem       = TrayCreateItem("Exit")

TraySetState()
TraySetClick(16)

Global $MyPopServer = "pop.free.fr"
Global $MyLogin = "username"  ; login name only
Global $MyPasswd = "password"

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("Inem Mail", 500, 480)
$sLVhdr = "ID|Date|From|Subject"
$aLVhdr = StringSplit($sLVhdr, "|")
$ListView1 = GUICtrlCreateListView($sLVhdr, 100, 34, 390, 169)
GUICtrlSendMsg(-1, 0x101E, 0, 48)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlSendMsg(-1, 0x101E, 3, 140)
$Edit1 = GUICtrlCreateEdit("", 10, 220, 480, 249)
$TreeView1 = GUICtrlCreateTreeView(5, 34, 86, 169)
$TreeView1_0 = GUICtrlCreateTreeViewItem("INBOX", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Unread", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("Read", $TreeView1_0)
$TreeView1_3 = GUICtrlCreateTreeViewItem("All Mail", $TreeView1_0)
$TreeView1_4 = GUICtrlCreateTreeViewItem("Send Mail", $TreeView1)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Drafts", $TreeView1)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Spam", $TreeView1)
$Button1 = GUICtrlCreateButton("Compose", 4, 4, 65, 21, 0)
$Button2 = GUICtrlCreateButton("Send / Recieve", 72, 4, 85, 21, 0)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button2
            checkmail()
    EndSelect
WEnd

Func Click()
    _pop3Connect ($MyLogin, $MyPasswd,$MyPopServer)
    $iRow = _GUICtrlListView_GetNextItem($ListView1) ; current selected
    If $iRow = -1 Then Return
    $aMsgNum = StringSplit(_GUICtrlListView_GetItemText($ListView1, $iRow), " ")
    If $aMsgNum[0] = 1 Then Return
    GUICtrlSetData($Edit1, _Pop3Retr($aMsgNum[1]))
    _pop3Disconnect()
EndFunc   ;==>Click

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $iEvent
    If $wParam = $ListView1 Then
        $tagNMHDR = DllStructCreate("int;int;int", $lParam)
        $iEvent = DllStructGetData($tagNMHDR, 3)
        ;If $iEvent = $NM_DBLCLK Then Click()
        If $iEvent = $NM_CLICK Then Click()
    EndIf
EndFunc   ;==>WM_Notify_Events

Func checkmail()
    _pop3Connect($MyLogin, $MyPasswd,$MyPopServer)
    If @error Then
        MsgBox(262144 + 16, "", "Unable to connect to mail server @error=" & @error)
        Exit
    EndIf
    $aLoopNum = _Pop3Stat()
    $iCurrent = 0
    While $iCurrent < $aLoopNum[1]
        $iCurrent += 1
        $sMsgHdr = _Pop3Top($iCurrent, 1)
        $stat = _Pop3List($iCurrent)
        $sItem = $stat[1] & "|"
        For $i = 2 To $aLVhdr[0]
            $aItem = StringRegExp($sMsgHdr, "(" & $aLVhdr[$i] & " :) (.*[\r\n])", 3)
            If @error = 0 Then
                If UBound($aItem) = 2 Then
                    $sItem &= StringStripWS($aItem[1], 3) & "|"
                EndIf
            EndIf
            ;StringTrimRight($sItem, 1)
        Next
        GUICtrlCreateListViewItem($sItem, $ListView1)
    WEnd
    _pop3Disconnect()
EndFunc   ;==>checkmail

This exemple don't run with the new UDF !

Big thanks :unsure:

Edited by pierrotm777
Link to comment
Share on other sites

I try like this

#include <_POP3.au3>

If _POP3Connect ( "*********@live.fr", "********", "pop3.live.com" ) Then
    $a = _POP3Info()
    _ArrayDisplay($a)
    $b = _POP3List ( )
    _ArrayDisplay ( $b )
    _POP3Quit()
    _POP3Disconnect()
EndIf

If _POP3Connect ( "**********@gmail.com", "**********", "pop.gmail.com" ) Then
    $a = _POP3Info()
    _ArrayDisplay($a)
    $b = _POP3List ( )
    _ArrayDisplay ( $b )
    _POP3Quit()
    _POP3Disconnect()
EndIf

but unsucessfully...

Edit : my gmail account is actived for pop.

Gmail use a SSL mode , so this UDF don't run with
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...