#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <WinHttp_GetRespond.au3>
#include <array.au3>
Opt('GUIDataSeparatorChar','!')
Dim $rContext,$QQNum,$UUI,$Tie
Global $SendName,$SendID,$UrlSid,$QQNum,$SenQNum,$CodeY
Dim $TxSendTxt,$Sid,$HeaderUrl
$Form2 = GUICreate("邮件发送测试", 337, 439, 341, 157)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 8, 43, 17)
$Input1 = GUICtrlCreateInput("", 64, 5, 121, 21)
$Label2 = GUICtrlCreateLabel("密 码:", 24, 35, 43, 17)
$Input2 = GUICtrlCreateInput("", 64, 32, 121, 21,$ES_PASSWORD)
$Pic1 = GUICtrlCreatePic("", 192, 23, 130, 53)
$Label3 = GUICtrlCreateLabel("验证码:", 16, 59, 43, 17)
$Input3 = GUICtrlCreateInput("", 64, 56, 121, 21)
$Label4 = GUICtrlCreateLabel("点击图片换下一张..", 200, 0, 106, 17)
$Group1 = GUICtrlCreateGroup("", 3, 184, 329, 249)
$Label5 = GUICtrlCreateLabel("标题:", 16, 200, 31, 17)
$Input4 = GUICtrlCreateInput("标题", 48, 198, 265, 21)
$Label6 = GUICtrlCreateLabel("内容:", 16, 232, 31, 17)
$Edit1 = GUICtrlCreateEdit("内容", 16, 248, 305, 145)
;GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("登录", 72, 85, 147, 33)
$Button2 = GUICtrlCreateButton("提交", 128, 400, 75, 25)
$Radio1 = GUICtrlCreateRadio("选择", 8, 128, 57, 17)
GUICtrlSetState(-1,$GUI_CHECKED)
$Radio2 = GUICtrlCreateRadio("填写收件人", 8, 159, 89, 17)
$Combo1 = GUICtrlCreateCombo("", 64, 128, 265, 25,BitOR($CBS_DROPDOWN,$WS_VSCROLL,$CBS_DROPDOWNLIST))
GUICtrlSetState(-1,$GUI_DISABLE)
$Input5 = GUICtrlCreateInput("", 96, 157, 233, 21)
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetState(@SW_SHOW)
;Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
$MyOpen=_WinHttpOpen('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)')
$rContext=_WinHTTP_GetRespond($MyOpen,"https://mail.qq.com/cgi-bin/loginpage",4 + 2,50000,"")
_Get_Code()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
_WinHttpCloseHandle($MyOpen)
Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
Exit
Case $Pic1
_Get_Code()
Case $Combo1
GUICtrlSetData($Input5,GUICtrlRead($Combo1))
Case $Radio1
GUICtrlSetState($Input5,$GUI_DISABLE)
GUICtrlSetState($Combo1,$GUI_ENABLE)
Case $Radio2
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetState($Input5,$GUI_ENABLE)
Case $Button1
$NName = GUICtrlRead($Input1)
$NPwd = GUICtrlRead($Input2)
$NCode = GUICtrlRead($Input3)
_Loing($NName,$NPwd,$NCode)
Case $Button2
If GUICtrlRead($Combo1) <> '' And GUICtrlRead($Input4) <> '' And GUICtrlRead($Edit1) <> '' Then
$UUI = ''
$Tie = GUICtrlRead($Input4)
$Txt = GUICtrlRead($Edit1)
$SeN = GUICtrlRead($Combo1)
$CF = StringSplit($Txt,@LF)
For $i = $CF[0] To 1 Step - 1
If $CF[$i] <> '' Then
$TE = '<DIV>' & StringRegExpReplace($CF[$i],'(\r)','') & '</DIV>' & @CRLF
$UUI = StringReplace($TE & $UUI,'<DIV></DIV>','<DIV> </DIV>')
EndIf
Next
$PCF = StringSplit(GUICtrlRead($Combo1),'?')
;MsgBox(64,'提示',$PCF[1] & @CRLF & $PCF[2])
_SendTxt($SendName,$SendID,$UrlSid,$PCF[1],$PCF[2],$Tie,$UUI,'');;提交
EndIf
EndSwitch
WEnd
Func _Loing($Name,$PWD,$Code)
If $Name <> '' And $PWD <> '' And $Code <> '' Then
GUICtrlSetState($Button1,$GUI_DISABLE)
$Context = 'sid=%2C2%2Czh_CN&firstlogin=false&starttime=1302438026859&redirecturl=&f=html&p=' & $PWD & '&ept=0&delegate_url=&s=&ts=1302430206&from=&ppp=&chg=0&target=&checkisWebLogin=3&uin=' & $Name & '&aliastype=@qq.com&pp=00000000&verifycode='&$Code
$rContext=_WinHTTP_GetRespond($MyOpen,"https://mail.qq.com/cgi-bin/login?sid=,2,zh_CN",1 + 4 + 2,50000,$Context,'',"Content-Type: text/html; charset=gbk")
If @error Then MsgBox(0,@error,"出错了")
;MsgBox(64,'Cookies',$rContext[3])
;MsgBox(64,'编码类型',$rContext[5])
;MsgBox(64,'完整Header',$rContext[6])
;MsgBox(64,'数据内容',BinaryToString($rContext[0]))
$HeaderUrl = StringRegExp(BinaryToString($rContext[0]),'urlHead="(.+?)";', 3);;返回Header网址
$CookSid = StringRegExp(BinaryToString($rContext[3]),'qm_sid=(.+?),', 3);;Cookiesqm_sid码
$RtSid = StringRegExp(BinaryToString($rContext[0]),'sid=(.+?)";', 3);;返回本次会话的SID
If @error = 0 Then
;MsgBox(64,'提示','成功登录')
$QQNum = GUICtrlRead($Input1)
$QQIDUrl = $HeaderUrl[0] & 'grouplist?t=compose_group&sid=' & $RtSid[0] & '&newwin=true&nocheckframe=true'
$rContext=_WinHTTP_GetRespond($MyOpen,$QQIDUrl,4 + 2,50000,'','',"Content-Type: text/html; charset=UTF-8")
$UrlSid = $RtSid[0]
If @error Then MsgBox(0,@error,"出错了")
;MsgBox(64,'Cookies',$rContext[3])
;MsgBox(64,'编码类型',$rContext[5])
;MsgBox(64,'完整Header',$rContext[6])
;MsgBox(64,'数据内容',BinaryToString($rContext[0]))
$OkHtml = StringRegExpReplace(BinaryToString($rContext[0]),'(\s)','');;返回网页源码并删除回车空格
$GuID1 = StringRegExp($OkHtml,'<optionid="Gname_(.+?)</option>', 3);;
;_ArrayDisplay($GuID1)
For $i = 0 To UBound($GuID1) - 1
$CFTx = StringSplit($GuID1[$i],'"')
If $CFTx[0] <= 4 Then
;MsgBox(64,'提示',StringReplace($CFTx[4],'>','') & @CRLF & $CFTx[3])
$QQMaiID = StringReplace($CFTx[4],'>','') & '?' & $CFTx[3]
GUICtrlSetData($Combo1,$QQMaiID,StringReplace($CFTx[4],'>','') & '?' & $CFTx[3])
EndIf
Next
GUICtrlSetState($Combo1,$GUI_ENABLE)
$NewUrl = $HeaderUrl[0] & 'readtemplate?sid=' & $RtSid[0] & '&t=compose&s=cnew&loc=frame_html,,,21';;转到写信页面取发送ID
$rContext=_WinHTTP_GetRespond($MyOpen,$NewUrl,4 + 2,50000)
If @error Then MsgBox(0,@error,"出错了")
;MsgBox(0,$rContext[3],$rContext[6])
$OkHtml = StringRegExpReplace(BinaryToString($rContext[0]),'(\s)','');;返回网页源码并删除回车空格
;FileWriteLine('哈哈.txt',$OkY)
$SendIDK = StringRegExp($OkHtml,'"/><inputtype="hidden"name="(.+?)<inputtype="hidden"name="sid"value="', 3);;返回所需的发送ID号
$SIDCF = StringSplit($SendIDK[0],'"')
$SendName = $SIDCF[1];发送代码Name
$SendID = $SIDCF[3];发关代码ID
;MsgBox(64,'提示','发送代码Name:' & $SendName & @CRLF & '发送代码ID:' & $SendID)
Else
MsgBox(48,'提示','登录失败')
GUICtrlSetState($Button1,$GUI_ENABLE)
Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
_Get_Code()
GUICtrlSetData($Input3, "")
EndIf
EndIf
EndFunc
Func _SendTxt(ByRef $S1,ByRef $S2,ByRef $Sid,ByRef $GQName,ByRef $GQNum,ByRef $Tile,ByRef $SendTxt,$CodeY);;提交
GUICtrlSetState($Button2,$GUI_DISABLE)
If $S1 <> '' And $S2 <> '' And $Sid <> '' And $GQName <> '' And $GQNum <> '' And $Tile <> '' And $SendTxt <> '' Then
$TxSendTxt = '-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="sid"'&@CRLF&@CRLF& $Sid &@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="actiontype"'&@CRLF&@CRLF&'send'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="bigattachcnt"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="priority"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="contenttype"'&@CRLF&@CRLF&'html'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="savesendbox"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="sendname"'&@CRLF&@CRLF&'alias'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="qqshow"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="fmailid"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="cattachelist"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="fattachlist"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="rsturl"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="fileidlist"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="verifykey"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="verifycode"'&@CRLF&@CRLF& $CodeY &@CRLF& _;;验证码
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="verifycode_cn"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="t"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="s"'&@CRLF&@CRLF&'group'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="contenttext"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="hitaddrbook"'&@CRLF&@CRLF&'0'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="backurl"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="newwin"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="mailtype"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="sid"'&@CRLF&@CRLF& $Sid &@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="' & $S1 & '"'&@CRLF&@CRLF& $S2 &@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="groupname"'&@CRLF&@CRLF& $GQName &@CRLF& _;;Q名称
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="qqgroupid"'&@CRLF&@CRLF& $GQNum &@CRLF& _;;Q号码
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="subject"'&@CRLF&@CRLF& $Tile &@CRLF& _;;标题
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="votesubject"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="votetype"'&@CRLF&@CRLF&'secret'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="option"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="option"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="option"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="content__html"'&@CRLF&@CRLF& $SendTxt & _;;内容
'-----------------------------7db2802d1d023a--'&@CRLF
;'Referer: '& $HeaderUrl[0] &'grouplist?t=compose_group&newwin=&sid=' & $Sid & @CRLF & _
$HeUrl1 = StringSplit($HeaderUrl[0],'/');;拆分网址
;_WinHttpQueryHeaders($MyOpen,'Host',$HeUrl[3])
$HeaderAdd = 'Accept-Language: zh-cn' & @CRLF & 'Content-Type: multipart/form-data; boundary=---------------------------7db7d61d023a' & @CRLF & _
'Host: ' & $HeUrl1[3] & @CRLF & 'Content-Length: ' & StringLen(BinaryToString($TxSendTxt)) & @CRLF & 'Connection: Keep-Alive' &@CRLF& _
'Cache-Control: no-cache'
FileWriteLine(@ScriptDir & '\日志.txt','提交地址:' & $HeaderUrl[0] & "groupmail_send?sid=" & $Sid)
FileWriteLine(@ScriptDir & '\日志.txt','Header:' & $HeaderAdd)
FileWriteLine(@ScriptDir & '\日志.txt','提交内容:' & $TxSendTxt & @CRLF)
$rContext=_WinHTTP_GetRespond($MyOpen,$HeaderUrl[0] & "groupmail_send?sid=" & $Sid,1 + 4 + 2,50000,$TxSendTxt,'',$HeaderAdd)
If @error Then MsgBox(0,@error,"出错了")
MsgBox(64,'Cookies',$rContext[3])
MsgBox(64,'编码类型',$rContext[5])
MsgBox(64,'完整Header',$rContext[6])
MsgBox(64,'数据内容',BinaryToString($rContext[0]))
;FileWriteLine(@ScriptDir & '\日志.log','完整Header:' & $rContext[6])
;FileWriteLine(@ScriptDir & '\日志.log','数据内容:' & BinaryToString($rContext[0]))
If StringInStr(BinaryToString($rContext[0]),'发送成功') Then
MsgBox(64,'提示','邮件发送成功')
Else
MsgBox(48,'提示','邮件发送失败')
EndIf
Else
EndIf
GUICtrlSetState($Button2,$GUI_ENABLE)
EndFunc
Func _Get_Code()
$rContext=_WinHTTP_GetRespond($MyOpen,"https://mail.qq.com/cgi-bin/getverifyimage?aid=23000101&f=html&ck=1&"&@SEC ,4 + 2 ,50000)
If @error Then Return MsgBox(0,@error,"出错了")
$CodeFile = FileOpen(@TempDir & "\code.bmp",10)
FileWrite($CodeFile,Binary($rContext[0]))
FileClose($CodeFile)
GUICtrlSetImage($Pic1,@TempDir & "\code.bmp")
EndFunc