MODIFIED =20071202 SCRNAMES =LV_EMAIL_03.ahk ; ; script from 20071124 Ripp3r]D3[ http://de.autohotkey.com/forum/topic2188.html ; ;---------------------- FREEWARE STANDALONE ------------ DOWNLOAD ------------------------ ;---popclient.exe ----- http://www.codeode.com/ http://www.codeode.com/popclient/popclient.exe ;receive ;---vmailer.exe ----- http://virdi-software.com http://virdi-software.com/vmailer/vmail121.zip ;send ; ; OR/AND (send also attachment drag&drop ) : ;---blat.exe ----- http://www.blat.net http://downloads.sourceforge.net/blat/blat262.full.zip ;send ;---blat.dll ;---------------------------------------------------------------------------------------------------------- ; ; own_INPOPSERVER =pop.bluewin.ch ; own_SMTP =mail.bluewin.ch ; own_emailadress =garry1411@bluewin.ch ; own_password1 =123456ABCD ; ;--------- http://www.autohotkey.net/~garry/Email01.jpg ;--------- http://www.autohotkey.net/~garry/LV_EMAIL_01.ahk ; ; Can send attachment with blat.exe ; This script only receive text , otherwise use Thunderbird Portable= ; http://portableapps.com/ ; ; #NoEnv #SingleInstance force SetBatchLines,-1 setworkingdir, %a_scriptdir% AutoTrim Off transform,S,chr,32 FileInstall, popclient.exe,popclient.exe,1 FileInstall, VMailer.exe,VMailer.exe,1 FileInstall, Blat.exe,Blat.exe,1 FileInstall, Blat.dll,Blat.dll,1 ;----------- your original data's need only the first time -- ;----------- writes to ini after first start ---------------- own_INPOPSERVER =pop.bluewin.ch own_SMTP =mail.bluewin.ch own_emailadress =garry1411@bluewin.ch own_password1 =123456ABCD ;---- for BLAT.exe ----- binfil=_FileBinary.txt txtfil=_FileText.txt inlfil=_FileInline.txt ;try to fill body always with same message here with date ;---------------------------- SIZE=20000 ;define size here to show in edit box otherwise opens notepad NPEX=0 ifnotexist,POPCLIENT.EXE NPEX=1 ifnotexist,VMAILER.EXE NPEX=1 if NPEX=1 { text31= ( Download -vmailer.exe -popclient.exe from http://www.codeode.com/ http://virdi-software.com http://www.blat.net Want you download these programs ? ) msgbox, 262180, Start URL,%text31% ifmsgbox,NO { exitapp return } else { ;run,http://www.codeode.com/ ;run,http://virdi-software.com ;http://www.blat.net run,http://www.codeode.com/popclient/popclient.exe run,http://virdi-software.com/vmailer/vmail121.zip run,http://downloads.sourceforge.net/blat/blat262.full.zip exitapp return } } ;------------------------------------------------------ /* ================== POPCLIENT.EXE ===================================================== ;popclient.exe= ;http://www.downloadjunction.com/product/store/18358/index.html http://www.codeode.com/ http://www.codeode.com/popclient/popclient.exe < Received: from mail15.networld.com (195.111.XX.UU) by mssezhh.msg.networld.com (networld 7.3.121) id 46517FE51248855C for garry@networld.com; Thu, 29 Nov 2007 14:31:00 +0000 <<< TIME RECEIVED +1 hour GMT switzerland Received: from [192.XXX.U.ZZ] (85.X.UUU.ZZZ) by mail15.networld.com (networld 7.3.121) id 471B438B00ADE66E for xyzz@networld.com; Thu, 29 Nov 2007 14:31:00 +0000 Message-ID: <474EC777F.4039999@networld.com> Date: Thu, 29 Nov 2007 15:31:11 +0100 <<< DATE SENT (not used) From: garry <<< FROM User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) To: xxxyy@networld.com Subject: TEST <<< SUBJECT */ IniRead,Server2 , Server.ini ,Host1 ,Host ,%own_INPOPSERVER% IniRead,SMTP2 , Server.ini ,SMTP1 ,SMTP ,%own_SMTP% IniRead,User2 , Server.ini ,User1 ,User ,%own_emailadress% IniRead,Password2, Server.ini ,Password1 ,Password ,%own_password1% Gui,1:default Gui,1:Color, 000000 Gui,1:Font,S10 CDefault,Verdana Gui,1:Add, ListBox, x6 y190 w460 h130 vList2 ReadOnly, Gui,1:Add, CheckBox, x6 y95 vCheck1 cWhite , Clear Mails -> Load and delete E-MAILs from server Gui,1:Add, CheckBox, x6 y115 checked cwhite vCheck2 , Load Once -> Load only not readed E-MAILs Gui,1:Add, Button, x10 y155 w100 h30 gGetMail,Get E-Mails Gui,1:Add, Button, x150 y155 w100 h30 gSend,Send-New ;ifexist blat >goto Blat else Vmailer ;Gui,1:Add, Button, x280 y155 w100 h30 gSendBlat ,Send-Attach Gui,1:Add, Edit,cWhite x476 y5 w770 h300 vMail Readonly, Gui,1:Add,Text,cWhite x10 y690 w47 vTOTAL1 , Gui,1:Add,Text,cWhite x60 y690 w550 vNames , Gui,1:Add,Text,cWhite x700 y690 ,Delete marked lines with rightclick ifexist,vmailer.exe NPX=1 ifexist,blat.exe NPY=1 if (NPX=1 AND NPY=1) { Gui,1:Add, Radio,cRed x200 y35 vACR ,VMAILER Gui,1:Add, Radio,cRed x300 y35 checked ,BLAT } ;--- correct this for width -- T1=320 T2=740 T3=170 T4=0 T1A:=T1 T2A:=T1+T2 T3A:=T1+T2+T3 T4A:=T1+T2+T3+T4 T5B:=T4A+40 T5C:=T4A+20 Gui,1:Add, ListView,x0 y320 grid r20 w%T5C% backgroundGray cWhite +hscroll altsubmit vMLV1 gMLV2, From|Subject|Date|TEXT LV_ModifyCol(1,T1) LV_ModifyCol(2,T2) LV_ModifyCol(3,T3) LV_ModifyCol(4,T4) Gui,1:Show, x1 y1 h720 w%T5B%, TEST EMAIL ;--------- variables readed from server.ini --------------------------------------------- Gui,1:Add, Edit, x6 y5 w160 h20 vServer2 ,%Server2% Gui,1:Add, Edit, x180 y5 w160 h20 vSMTP2 ,%SMTP2% Gui,1:Add, Text, cWhite x350 y5 w100 ,SMTP Gui,1:Add, Edit, x6 y35 w160 h20 vUser2 ,%User2% Gui,1:Add, Edit, x6 y65 w160 h20 Password vPassword2 ,%Password2% ;---------------------------------------------------------------------------------- gosub,getmail ;if you want get mail at start Return ;--------------------------------------------------------------- MLV2: Gui,1:submit,nohide GuiControlGet,MLV1 RN:=LV_GetNext("C") RF:=LV_GetNext("F") GC:=LV_GetCount() if A_GuiEvent = Normal { if (RF="" OR RF=0) { return } MouseGetPos,x,y { if x<%T1A% { LV_GetText(C1,A_EventInfo,1) GuiControl,1:,Names,%C1% return } if x<%T2A% { LV_GetText(C1,A_EventInfo,1) LV_GetText(C4,A_EventInfo,4) Filegetsize,SIZE2,%dir_emails%%username_email%\%C4% if size2>%SIZE% { GuiControl,1:,Mail,Size is >%SIZE% GuiControl,1:,Names,%C1% run,%dir_emails%%username_email%\%C4% ;open text file when to big return } FileRead,Readmaile,%dir_emails%%username_email%\%C4% GuiControl,1:,Mail,%Readmaile% GuiControl,1:,Names,%C1% return } if x<%T3A% return if x<%T4A% return } } if A_GuiEvent=K { GetKeyState,state,UP if state=D { RF:=LV_GetNext("F") LV_GetText(C1,RF,1) LV_GetText(C4,RF,4) Filegetsize,SIZE2,%dir_emails%%username_email%\%C4% if size2>%SIZE% { GuiControl,1:,Mail,Size is >%SIZE% LeftClick to subject GuiControl,1:,Names,%C1% return } FileRead,Readmaile,%dir_emails%%username_email%\%C4% GuiControl,1:,Mail,%Readmaile% GuiControl,1:,Names,%C1% } GetKeyState,state,DOWN if state=D { RF:=LV_GetNext("F") LV_GetText(C1,RF,1) LV_GetText(C4,RF,4) Filegetsize,SIZE2,%dir_emails%%username_email%\%C4% if size2>%SIZE% { GuiControl,1:,Mail,Size is >%SIZE% LeftClick to subject GuiControl,1:,Names,%C1% return } FileRead,Readmaile,%dir_emails%%username_email%\%C4% GuiControl,1:,Mail,%Readmaile% GuiControl,1:,Names,%C1% } } /* ;--------- DELETE ONE ---------------------------- if A_GuiEvent = RightClick { if (RF="" OR RF=0) return LV_GetText(C2,RF,2) LV_GetText(C4,RF,4) MsgBox, 4, ,Want you really delete %C2% ? IfMsgBox,No Return Else { GuiControl,1:,Mail,%nothing% ;clear Edit4 filerecycle,%dir_emails%%username_email%\%C4% LV_Delete(RF) RN=0 filedelete,%F84% Loop % LV_GetCount() { RN++ BX1= BX2= BX3= BX4= LV_GetText(BX1,A_INDEX,1) LV_GetText(BX2,A_INDEX,2) LV_GetText(BX3,A_INDEX,3) LV_GetText(BX4,A_INDEX,4) fileappend,%BX1%;%BX2%;%BX3%;%BX4%`r`n,%F84% } } gosub,filllist return } */ ;--------- DELETE MULTIPLE ---------------------------- if A_GuiEvent = RightClick { C2x= C4x= RF = 0 RFL = Z=0 Loop { RF:=LV_GetNext(RF) if RF=0 break RFL = %RF%|%RFL% LV_GetText(C2_Temp, RF, 2) LV_GetText(C4_Temp, RF, 4) C2x = %C2x%`n%C2_Temp% C4x = %C4x%;%C4_Temp% } if C2x != { MsgBox, 4, ,Want you really delete %C2x% ? IfMsgBox,No Return Else { StringSplit,D,C4x,`; ;split `; as delimiter loop,%D0% { DY=%A_INDEX% ; 1 2 3 if DY=1 continue DX:=D%A_INDEX% ;string Filerecycle,%dir_emails%%username_email%\%DX% } Loop, parse, RFL, | { LV_Delete(A_LoopField) } filedelete,%F84% Loop % LV_GetCount() { BX1= BX2= BX3= BX4= LV_GetText(BX1,A_INDEX,1) LV_GetText(BX2,A_INDEX,2) LV_GetText(BX3,A_INDEX,3) LV_GetText(BX4,A_INDEX,4) fileappend,%BX1%;%BX2%;%BX3%;%BX4%`r`n,%F84% } } } gosub,filllist return } return ;------------------------------------------------------------ GuiClose: ExitApp ;------------------------------------------------------------ GetMail: Gui,1:submit,nohide GuiControl,1:,List2,| ;clear listbox2 GuiControl,1:,Mail,%nothing% ;clear Edit4 IniWrite,%Server2% , Server.ini ,Host1 ,Host IniWrite,%SMTP2% , Server.ini ,SMTP1 ,SMTP IniWrite,%User2% , Server.ini ,User1 ,User IniWrite,%Password2% , Server.ini ,Password1 ,Password ;---Clear Mails -> Load emails and delete from server ;---Load Once -> Load only not readed ;---- for test = ----------------------------------- /* text11= ( check1=%check1% check2=%check2% server2=%server2% smtp2=%smtp2% user2=%user2% password2=%password2% ) msgbox,%text11% return */ if (Check1=1) { entf=true ;after download delete from server ;ifexist,%A_ScriptDir%\emails\%User%\*.txt ; filerecycle,%A_ScriptDir%\emails\%User%\*.txt ;delete all existing own files } else { entf=false } if (Check2=1) { Once=true } else { Once=false } pop3=%Server2% username_email=%User2% password_email=%Password2% dir_emails=%A_ScriptDir%\emails\ FileCreateDir, %dir% IfNotExist %dir_emails%%username_email% FileCreateDir, %dir_emails%%username_email% mail= ( %pop3% 110 %username_email% %password_email% %dir_emails%%username_email% %entf% %Once% ) bat= ( popclient.exe -configfile email_config.xml ) filedelete email_config.xml fileappend, %mail%, email_config.xml filedelete Mail.bat fileappend, %bat%, Mail.bat filedelete Log.txt GuiControl,1:, List2,Please Wait... runwait,Mail.bat >Log.txt ,,hide sleep,200 Loop, Read,%A_ScriptDir%\Log.txt GuiControl,1:, List2,%A_LoopReadLine% F82=receivedmails.txt ifexist,%F82% Filedelete,%F82% ;----------- ORIG ------------------------- Loop, %dir_emails%%username_email%\*.txt, , 1 Fileappend,%A_LoopFileName%`r`n,%F82% ;-------------------------------- READ txt -------------------------------------- ; id 46517FE511E327CA for xyz@networld.com; Sun, 25 Nov 2007 08:45:41 +0000 ;From:xyzz@networld.com ;Subject:test66 F84=FromSubject.txt ifexist,%F84% Filedelete,%F84% ;------------------------------------------------------------------------------------------------ ;search= FROM SUBJECT RECEIVED DATE EMAIL ;garry1411@bluewin.ch ;Hello ;20071130 14:44 ;_873416D88D06AB34EC381883F2052628.txt ;----------------- F84 must have this form otherwise correct ------------------------------------ loop,read,%F82% { LR1=%A_loopreadline% I:=0 FOUND=0 loop,read,%dir_emails%%username_email%\%LR1% { I++ LR2=%A_loopreadline% stringmid,FR1,LR2,1,5 stringmid,SB1,LR2,1,8 stringmid,XMS,LR2,1,5 ;id 46517FE5122E1709 for xyzz@networld.com; Wed, 28 Nov 2007 10:37:47 +0000 ;search for this and split by comma { if (I>2 AND I<5) ;search Line 3...4 for date { FileReadLine,LR3,%dir_emails%%username_email%\%LR1%,%I% { StringSplit,BC,LR3,`, stringmid,LR3a,BC2,2,27 ;date 28 Nov 2007 10:37:47 +0000 gosub,calculate continue } } } if FR1=From: { Stringmid,FR2,LR2,6,100 if (((SB2="" AND SB1="Subject:") OR SB2<>"") AND LR3a<>"") { Fileappend,%FR2%;%SB2%;%LR3a%;%LR1%`r`n,%F84% ;FROM - SUBJECT - DATUM - FILE.txt L3a= FR2= SB2= SB1= FOUND=1 break ;break this loop and continue } } if SB1=Subject: { Stringmid,SB2,LR2,9,200 if (FR2<>"" AND LR3a<>"") { Fileappend,%FR2%;%SB2%;%LR3a%;%LR1%`r`n,%F84% L3a= FR2= SB2= SB1= FOUND=1 break } } } if FOUND=0 { Fileappend,%FR2%;%SB2%;%LR3a%;%LR1%`r`n,%F84% L3a= FR2= SB2= SB1= FOUND=1 } } ;-------------------------------------------------------------- FILLLIST: IX2=0 LV_Delete() loop,read,%F84% { IX2++ stringsplit,BX,A_LoopReadLine,`;, LV_Add("",BX1,BX2,BX3,BX4) } GuiControl,1:,Total1,%IX2% LV_ModifyCol(3, "SortDesc") RF=1 LV_Modify(RF, "+Select +Focus") LV_GetText(C4,RF,4) ; -- read last ----- FileRead,Readmaile,%dir_emails%%username_email%\%C4% GuiControl,1:,Mail,%Readmaile% return ;----------------------------------------------------------------- ;------------- CALCULATE 28 Nov 2007 10:37:47 +0500 ------------- CALCULATE: ;1 Dec 2007 14:25:19 +0000 ;30 Nov 2007 12:09:00 +0000 AMONTHS=Jan,Fev,Mar,Avr,Mai,Jun,Jul,Aug,Sep,Oct,Nov,Dec StringSplit,D,AMONTHS,`, Stringsplit,LD,LR3a,%S% ;control if date 1 digit stringlen,SL1,LD1 if SL1=1 DAYS2=0%LD1% else DAYS2=%LD1% if SL1=1 { Stringmid,MONS2,LR3a,3,3 ; Nov Stringmid,YYYY2,LR3a,7,4 Stringmid,TIMS2,LR3a,12,8 } else { Stringmid,MONS2,LR3a,4,3 ; Nov Stringmid,YYYY2,LR3a,8,4 Stringmid,TIMS2,LR3a,13,8 Stringmid,DAYS2,LR3a,1,2 } Stringmid,HOUR2,TIMS2,1,2 Stringmid,MINS2,TIMS2,4,2 Stringmid,SECS2,TIMS2,7,2 TIME2=%HOUR2%%MINS2%%SECS2% ;140359 loop,%D0% ;look for months { DY2=%A_INDEX% ; 1 2 3 DX2:=D%A_INDEX% ;string if DY2<10 DY2=0%DY2% if DX2=%MONS2% break } DATE1=%YYYY2%%DY2%%DAYS2%%TIME2% ;------ GMT GreenwichMeanTime --- ;-------calculate DATE for switzerland + 1 hour when email received --- EnvAdd,DATE1,1,hours ;add 1 hour to +0000 GMT stringmid,DATE1a,DATE1,1,8 stringmid,DATE1b,DATE1,9,2 stringmid,DATE1c,DATE1,11,2 LR3a=%DATE1a% %DATE1b%:%DATE1c% return ;---------------------------- END CALCULATE ---------------------------- SEND: Gui,1:submit,nohide if ACR=2 goto,SendBlat ;================================================================================== ;-------------------- VMAILER.exe ------------------------------------------------- SendVmail: Gui,1:submit,nohide IniRead,Server2 , Server.ini ,Host1 ,Host ,%own_INPOPSERVER% IniRead,SMTP2 , Server.ini ,SMTP1 ,SMTP ,%own_SMTP% IniRead,User2 , Server.ini ,User1 ,User ,%own_emailadress% IniRead,Password2, Server.ini ,Password1 ,Password ,%own_password1% Gui, 2:+owner1 Gui 1: +Disabled Gui,2:Color, 000000 Gui,2:Font,S10 CDefault,Verdana Gui 2:Add, Text, x6 y10 cWhite ,SendTo Gui 2:Add, Edit, x60 y10 w490 h20 vSendto ,%User2% ;for test send to me Gui 2:Add, Text, x6 y40 cWhite ,Subject Gui 2:Add, Edit, x60 y40 w490 h20 vLN2, Gui 2:Add, Edit, x6 y80 w750 h340 vMsg, ;messagebox Gui 2:Add, Button, x670 y25 w90 h30 gSendNow1, Send Gui 2:Show, x131 y91 w770 h430 , Send Vmailer Return ;---------- 2GuiClose: 2GuiEscape: Gui, 1:-Disabled Gui, 2: Destroy return ;-------------------------------------------------------- SENDNOW1: Gui,2:submit,nohide VMAILER=%A_ScriptDir%\vmailer.exe F7ac=result2.txt ifexist,%F7ac% Filedelete,%F7ac% ;Fileappend,From:BBC_NEWS`r`nSubject:%LN2%`r`n`r`n%MSG%,%F7ac% Fileappend,From:%USER2%`r`nSubject:%LN2%`r`n`r`n%MSG%,%F7ac% ;runwait,%comspec% /k "%VMAILER%" %F7ac% %SMTP2% %SENDTO% %USER2% ;for test runwait,%VMAILER% %F7ac% %SMTP2% %SENDTO% %USER2% Gui, 1:-Disabled Gui, 2: Destroy return ;========================= END VMAILER.exe ================================================== ;================================================================================== ;-------------------- BLAT.exe ------------------------------------------------- SendBlat: Gui,1:submit,nohide IniRead,Server2 , Server.ini ,Host1 ,Host ,%own_INPOPSERVER% IniRead,SMTP2 , Server.ini ,SMTP1 ,SMTP ,%own_SMTP% IniRead,User2 , Server.ini ,User1 ,User ,%own_emailadress% IniRead,Password2, Server.ini ,Password1 ,Password ,%own_password1% ifexist,%binfil% filedelete,%binfil% ifexist,%txtfil% filedelete,%txtfil% ;-- idea to fill body always with the same message here write only date when send ifexist,%inlfil% filedelete,%inlfil% ;Gui,3:+owner1 ;Gui 1: +Disabled ;Gui,3:default Gui,3:Color, 000000 Gui,3:Font,S10 CDefault,Verdana Gui 3:Add, Text, x6 y10 cWhite ,SendTo Gui 3:Add, Edit, x60 y10 w490 h20 vSendto ,%User2% ;for test send to me Gui 3:Add, Text, x6 y40 cWhite ,Subject Gui 3:Add, Edit, x60 y40 w490 h20 vLN2, Gui 3:Add, Edit, x6 y80 w750 h340 vMsg1, ;messagebox Gui 3:Add, Text, x100 y440 cWhite ,ATTACHMENTS Gui 3:Add, Edit,cWhite x6 y460 w750 h350 vMsg2 readonly, ;ATTACH input files her Gui 3:Add, Button, x570 y25 w90 h30 gClearMSG2, CLEAR-ATT Gui 3:Add, Button, x670 y25 w90 h30 gSendNow2, Send Gui 3:Show, x10 y30 w770 h830 , Send Blat Return ;--------------- 3GuiClose: 3GuiEscape: ;Gui, 1:-Disabled Gui, 3: Destroy return ;----------------- ;--------------------- drag&drop ----------------------------------------------- 3GuiDropFiles: Gui,3:submit,nohide Loop, parse, A_GuiEvent, `n { SelectedFileName = %SelectedFileName%`r`n%A_LoopField% ;write files-names SplitPath,A_loopfield, name, dir, ext, name_no_ext, drive if ext=txt Fileappend,%A_LoopField%`,,%txtfil% else Fileappend,%A_LoopField%`,,%binfil% } GuiControl,3:,MSG2,%SelectedFileName% return ;--------------------------------------------------------------------------- CLEARMSG2: Selectedfilename= GuiControl,3:,MSG2,%nothing% return ;-------------------------------------------------------- SENDNOW2: Gui,3:submit,nohide FileLog=blat.log ifexist,%FileLog% filerecycle,%Filelog% ifnotexist,%txtfil% Fileappend,,%txtfil% ifnotexist,%binfil% Fileappend,,%binfil% if MSG1= MSG1=Empty Message from %USER2% if LN2= LN2=Sent %A_NOW% from %USER2% Fileappend,Sent %A_NOW%`r`n,%inlfil% SplashImage,Vmailer,m2,Wait....`nBlat-mailer is now sending to %SendTo% sleep,500 ; -f ;Runwait,%comspec% /K Blat - -body "%MSG1%" -subject "%LN2%" -to %SENDTO% -atf %txtfil% -af %binfil% -attachi test33.txt Runwait,%comspec% /c Blat - -body "%MSG1%" -subject "%LN2%" -to %SENDTO% -attachi %inlfil% -atf %txtfil% -af %binfil% -log %FileLog% -timestamp,,hide SplashImage, Off ifexist,%binfil% filedelete,%binfil% ifexist,%txtfil% filedelete,%txtfil% ifexist,%inlfil% filedelete,%inlfil% SelectedFileName= GuiControl,3:,MSG2,%nothing% AAA1= Fileread,AAA1,%filelog% SplashImage,Vmailer,x200 y400 w700 m2,Blat-mailer sent to %SendTo%`n`n%AAA1% ;Gui, 1:-Disabled Gui, 3: Destroy return ;========================= END BLAT.exe ==================================================