Clever1mba Posted July 1, 2005 Posted July 1, 2005 (edited) hello i hope u guyz like this email sending codebut i need to improve this code i have problem in tcpRecv need to get all recv command and displayany one like to improve this code then it will be gr8#include <GUIConstants.au3>GUICreate("SMTP 25 1.1 by AsimZameer") GUICtrlCreateLabel ("Smtp :", 20, 10, 50) GUICtrlCreateLabel ("From :", 20, 40, 50) GUICtrlCreateLabel ("To :", 20, 70, 50) GUICtrlCreateLabel ("Name :", 20, 100, 50) GUICtrlCreateLabel ("Subject :", 20, 130, 50) GUICtrlCreateLabel ("Body :", 20, 160, 50) GUICtrlCreateLabel ("Status :", 5, 215, 50) $input1 = GUICtrlCreateInput("mx1.mail.yahoo.com",70,10,250,20)$input2 = GUICtrlCreateInput("snip",70,40,250,20)$input3 = GUICtrlCreateInput("snip",70,70,250,20)$input4 = GUICtrlCreateInput("asimzameer",70,100,250,20)$input5 = GUICtrlCreateInput("test message",70,130,250,20)$input6 = GUICtrlCreateInput("Hello WOW ASIM SMTP really Works",70,160,250,20)$myedit=GUICtrlCreateEdit ("Readme: After click on Send Button Wait Until status = 3 When Status = 3 it Means Email Successfully sent & Please Fill all Boxs Correctly If SMTP Address Not Works Automatically Exit and Close "& @CRLF, 1,230,400,70,$WS_DISABLED)$btn = GUICtrlCreateButton ("Send", 160, 310, 60, 20)GUISetState ()While 1$msg = GUIGetMsg()If $msg = $GUI_EVENT_CLOSE Then ExitLoopIf $msg = $btn Then$g_IP = GUICtrlRead($input1)$sData1 = "HELO " & GUICtrlRead($input4) & @CRLF$sData2 = "MAIL FROM: <" & GUICtrlRead($input2) &">" & @CRLF$sData3 = "RCPT TO: <" & GUICtrlRead($input3) &"> "& @CRLF$sData4 = "DATA" & @CRLF$sData5 = "From:" & GUICtrlRead($input4) & "< " & GUICtrlRead($input2) &" >" & @CRLF$sData6 = "To:" & GUICtrlRead($input3) & @CRLF$sData7 = "Subject:" & GUICtrlRead($input5) & @CRLF$sData8 = "Sender: Microsoft Outlook Express 6.00.2800.1158" & @CRLF$sData9 = "Mime-Version: 1.0" & @CRLF$sData10 = "Content-Type: text/plain; charset=US-ASCII" & @CRLF$sData11 = @CRLF$sData12 = GUICtrlRead($input6) & @CRLF$sData13 = "." & @CRLFTCPStartUp()$socket = TCPConnect(TCPNameToIP($g_IP), 25)If $socket = -1 Then Exit$ret1 = GUICtrlSetData ($myedit,TCPSend($socket, $sData1) )sleep(100)$ret2 = GUICtrlSetData ($myedit,TCPSend($socket, $sData2) )sleep(100)$ret3 = GUICtrlSetData ($myedit,TCPSend($socket, $sData3) )sleep(100)$ret4 = GUICtrlSetData ($myedit,TCPSend($socket, $sData4) )sleep(100)$ret5 = GUICtrlSetData ($myedit,TCPSend($socket, $sData5) )sleep(100)$ret6 = GUICtrlSetData ($myedit,TCPSend($socket, $sData6) )sleep(100)$ret7 = GUICtrlSetData ($myedit,TCPSend($socket, $sData7) )sleep(100)$ret8 = GUICtrlSetData ($myedit,TCPSend($socket, $sData8) )sleep(100)$ret9 = GUICtrlSetData ($myedit,TCPSend($socket, $sData9) )sleep(100)$ret10 = GUICtrlSetData ($myedit,TCPSend($socket, $sData10) )sleep(100)$ret11 = GUICtrlSetData ($myedit,TCPSend($socket, $sData11) )sleep(100)$ret12 = GUICtrlSetData ($myedit,TCPSend($socket, $sData12) )sleep(100)$ret13 = GUICtrlSetData ($myedit,TCPSend($socket, $sData13) )sleep(100)EndIfWendenjoy !!!!!!!!!!!!!----------------------------------------------------------------------- Edited November 8, 2012 by Melba23
Valuater Posted July 1, 2005 Posted July 1, 2005 You should probably post this code in AutoIt Forums > AutoIt v3 > Scripts and Scraps this is where people post programs.. and helpful stuff 8)
Skrip Posted December 6, 2005 Posted December 6, 2005 ERROR --- Line 38 TCPStartUp() ^ ERROR Error: Unknown function name. --- [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
Valuater Posted December 6, 2005 Posted December 6, 2005 (edited) ERROR---Line 38TCPStartUp()^ ERRORError: Unknown function name.---requires Beta versionhttp://www.autoitscript.com/forum/index.php?showtopic=10256#8) Edited December 6, 2005 by Valuater
memnon Posted December 6, 2005 Posted December 6, 2005 it works perfect and i use some of this code now for my syslog server das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?
Skrip Posted December 7, 2005 Posted December 7, 2005 Thanks I got it too work, but my status keeps going to 0 and won't change how do i fix this? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
Walkabout Posted December 8, 2005 Posted December 8, 2005 Asimzameer, Cool. I was so excited by this I've started to turn it into a UDF. I'll post it here when it's working. I've got a problem with the server unexpectely terminating the connection, and I'll be stuffed if I can work out why. Might have to post in support. Regards Walkabout. My Stuff:AutoIt for the MassesWait until Oracle Apps is readySend email natively from Autoit3
Walkabout Posted December 8, 2005 Posted December 8, 2005 Asimzameer, Cool. I was so excited by this I've started to turn it into a UDF. I'll post it here when it's working. I've got a problem with the server unexpectely terminating the connection, and I'll be stuffed if I can work out why. Might have to post in support. Regards Walkabout.Here it is (Thanks to MHz for his help) expandcollapse popup;=============================================================================== ; ; Function Name: _INetSmtpMail() ; Description: Sends an email using SMTP over TCP IP. ; Parameter(s): $s_SmtpServer - SMTP server to be used for sending email ; $s_FromName - Name of sender ; $s_FromAddress - eMail address of sender ; $s_ToAddress - Address that email is to be sent to ; $s_Subject - Subject of eMail ; $as_Body - Single dimension array containing the body of eMail as strings ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - 0 and sets ; @ERROR = 1 - Invalid Parameters ; @ERROR = 2 - Unable to start TCP ; @ERROR = 3 - Unable to resolve IP ; @ERROR = 4 - Unable to create socket ; @ERROR = 5 - Data send or SMTP Protocol error ; Authors: Original function to send email via TCP - Asimzameer ; Conversion to UDF - Walkabout ; ;=============================================================================== Func _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) Local $i_ReturnErrorCode Local $i_LocalErrorCode Local $v_Socket Local $s_IPAddress Local $i_SendReturn Local $i_Count Local $s_Send[10] If $s_SmtpServer = "" Or $s_FromAddress = "" Or $s_ToAddress = "" Or $s_FromName = "" Or StringLen($s_FromName) > 256 Then SetError(1) Return 0 EndIf $i_LocalErrorCode = TCPStartup() If $i_LocalErrorCode = 0 Then SetError(2) Return 0 EndIf StringRegExp($s_SmtpServer, "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)") If @extended Then $s_IPAddress = $s_SmtpServer Else $s_IPAddress = TCPNameToIP($s_SmtpServer) EndIf If $s_IPAddress = "" Then TCPShutdown() SetError(3) Return 0 EndIf $v_Socket = TCPConnect($s_IPAddress, 25) If $v_Socket = -1 Then TCPShutdown() SetError(4) Return (0) EndIf Sleep(100) $s_Send[0] = "HELO " & $s_FromAddress & @CRLF $s_Send[1] = "MAIL FROM: <" & $s_FromAddress & ">" & @CRLF $s_Send[2] = "RCPT TO: <" & $s_ToAddress & ">" & @CRLF $s_Send[3] = "DATA" & @CRLF $s_Send[4] = "From:" & $s_FromName & "< " & $s_FromAddress & " >" & @CRLF $s_Send[5] = "To:" & $s_ToAddress & @CRLF $s_Send[6] = "Subject:" & $s_Subject & @CRLF ;$s_Send[7] = "Sender: AutoIt3" & @CRLF $s_Send[7] = "Mime-Version: 1.0" & @CRLF $s_Send[8] = "Content-Type: text/plain; charset=US-ASCII" & @CRLF $s_Send[9] = @CRLF For $i_Count = 0 To UBound($s_Send) - 1 $i_SendReturn = TCPSend($v_Socket, $s_Send[$i_Count]) If $i_SendReturn = 0 Then TCPCloseSocket($v_Socket) TCPShutdown() SetError(5) Return 0 EndIf Sleep(100) $s_Receive = TCPRecv($v_Socket, 1000) Next Sleep(100) For $i_Count = 0 To UBound($as_Body) - 1 $i_SendReturn = TCPSend($v_Socket, $as_Body[$i_Count] & @CRLF) Sleep(100) If $i_SendReturn = 0 Then TCPCloseSocket($v_Socket) TCPShutdown() SetError(5) Return 0 EndIf $s_Receive = TCPRecv($v_Socket, 1000) Sleep(100) Next $i_SendReturn = TCPSend($v_Socket, @CRLF & "." & @CRLF) If $i_SendReturn = 0 Then TCPCloseSocket($v_Socket) TCPShutdown() SetError(5) Return 0 EndIf Sleep(100) TCPCloseSocket($v_Socket) TCPShutdown() Return 1 EndFunc ;==>_INetSmtpMail And simple wrapper script is: #include <INetSmtpMail.au3> $s_SmtpServer = "mysmtpserver.com.au" $s_FromName = "My Name" $s_FromAddress = "From eMail Address" $s_ToAddress = "To eMail Address" $s_Subject = "My Test UDF" Dim $s_Body[2] $s_Body[0] = "Testing the new email udf" $s_Body[1] = "Second Line" $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body) $err = @error msgbox(0,"email",$Response) msgbox(0,"error",$err) My Stuff:AutoIt for the MassesWait until Oracle Apps is readySend email natively from Autoit3
Walkabout Posted December 18, 2005 Posted December 18, 2005 Added to the UDF thread at the top of this forumLatest version of function (plus associated files)Walkabout. My Stuff:AutoIt for the MassesWait until Oracle Apps is readySend email natively from Autoit3
Skrip Posted December 19, 2005 Posted December 19, 2005 how do you attach a file to the e-mail? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
Walkabout Posted December 20, 2005 Posted December 20, 2005 how do you attach a file to the e-mail?Firestorm,At this stage you can't.Walkabout My Stuff:AutoIt for the MassesWait until Oracle Apps is readySend email natively from Autoit3
mikidutza Posted February 25, 2007 Posted February 25, 2007 you are a genius, i love your program!!!!!!!!!!!!!!!!!! keep up the good work
raquien Posted April 25, 2007 Posted April 25, 2007 this is not working for me.. i am in a network where we are using http proxy authentification for internet access...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now