Sign in to follow this  
Followers 0
keen

Email Help

4 posts in this topic

Im making an emial client using a Pop3 UDF I found here on the forum.

Here is the current script:

#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.1and1.com"
Global $MyLogin = "clicks@keen-studios.net"
Global $MyPasswd = "fakepasswordsothatnoonecansendusingmyemail"



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

#Region ### START Koda GUI section ### Form=C:\Users\Jordan Gensler\Downloads\IMAP_MAIL_1.0C(2)\IMAP MAIL\mail_Form1.kxf
$Form1_1 = GUICreate("Inem Mail", 466, 460, 284, 213)
$ListView1 = GUICtrlCreateListView("ID|Date|From|Title", 104, 32, 357, 169)
GUICtrlSendMsg(-1, 0x101E, 0, 40)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlSendMsg(-1, 0x101E, 3, 187)
$Edit1 = GUICtrlCreateEdit("", 0, 204, 461, 249, -1, 0)
$TreeView1 = GUICtrlCreateTreeView(0, 32, 101, 169)
$TreeView1_0 = GUICtrlCreateTreeViewItem("INBOX (2)", $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)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            checkmail()
        Case $ListView1
            _pop3Connect($MyPopServer, $MyLogin, $MyPasswd)
            $message = _pop3retr($ListView1)
            GUICtrlSetData ($Edit1, $message)

    EndSwitch
WEnd



Func checkmail()
    _pop3Connect($MyPopServer, $MyLogin, $MyPasswd)
If @error Then
        TrayTip("Inem Mail", "Unable to connect to mail server.", 1000)
Else
$sToolTipAnswer = TrayTip("Inem Mail", "Connected to mail server", 1000)

EndIf

$loopnumber = _Pop3Stat()
$current = 0
While $current <> $loopnumber[1]
    $current = $current + 1 String
    $messagedetails = _Pop3Top($current, 1)
    $stat = _Pop3List($current)
    $messagedetails = StringTrimLeft($messagedetails, 14)
    $messagedetails = StringTrimRight($messagedetails, 1)
    GUICtrlCreateListViewItem ($stat[1] & "|" & $messagedetails, $ListView1)
WEnd
_pop3Disconnect()
EndFunc

Here is what I need to know:

How can I get it so when I click the message, it will display in the edit?

How can I get the retrived messages to show correctly in the list view?


[center]Kesne's Bar & Grill[/center]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Here is what I need to know:

How can I get it so when I click the message, it will display in the edit?

How can I get the retrived messages to show correctly in the list view?

Try this, more error handling will be required. Also you may have to adjust the StringRegExp to get the listview headers date, from & subject in the format you want . It works OK for me with the pop3 and smtp servers I have access to.
#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.1and1.com"
Global $MyLogin = "clicks"  ; login name only
Global $MyPasswd = "fakepasswordsothatnoonecansendusingmyemail"

#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($MyPopServer, $MyLogin, $MyPasswd)
    $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($MyPopServer, $MyLogin, $MyPasswd)
    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
Edited by picaxe

Share this post


Link to post
Share on other sites

That works much better than what I had, but a lot of times it shows the subject in the date area. I'm not sure why it is doing this.

Also, my login name is clicks@keen-studios.net. 1and1.com has some really odd things about it, so that is my login name.


[center]Kesne's Bar & Grill[/center]

Share this post


Link to post
Share on other sites

That works much better than what I had, but a lot of times it shows the subject in the date area. I'm not sure why it is doing this.

As I mentioned, you may have to adjust the StringRegExp. However I would expect subject and date to appear on separate lines, check the full message text in the edit control to see if subject and date appear on the same line when this fault occurs.

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
Sign in to follow this  
Followers 0