Jack_10 Posted September 10, 2006 Share Posted September 10, 2006 (edited) hi there i use this script from this forum : expandcollapse popup#include<file.au3> Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom('mail.gmx.net', "DisplayName", "FROM YourAdress@xxx.xx", "TO YourAdress@xxx.xx", "Test Subject", "Test <b>Body</b>", "", "","", "Usernmae", "password") If @error then msgbox(0,"Error sending message","Error code:" & @error & " Description:" & $rc) EndIf Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "") $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Cc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Sent the Message $objEmail.Send if @error then SetError(2) return $oMyRet[1] EndIf EndFunc;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc;==>MyErrFunc and if i send 1st mail i have to wait minimum abount 60 seconds to send next the same mail. my program need to be send mail in different times (it can be even about every 5-10 sec) and if i try send it faster (less then every 60 sec) i get error Edited September 10, 2006 by Jack_10 Link to comment Share on other sites More sharing options...
AzKay Posted September 10, 2006 Share Posted September 10, 2006 Whats the error? # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Jack_10 Posted September 10, 2006 Author Share Posted September 10, 2006 (edited) Whats the error?Error code:2 Description : Cant send mail using server SMTP. Wrong code transport is : 0x800ccc67Server`s answer is : 421 Cannot connect to SMTP server 193.17.41.99(193.17.41.99:25), correct error 10060 Edited September 10, 2006 by Jack_10 Link to comment Share on other sites More sharing options...
Jack_10 Posted September 10, 2006 Author Share Posted September 10, 2006 do u have any ideas ? Link to comment Share on other sites More sharing options...
AzKay Posted September 10, 2006 Share Posted September 10, 2006 Try this one, Its got the SSL and Port in it. expandcollapse popup#include <file.au3> Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom("MailServer", "Your Name", "your@Email.Address.com", "CCadress1@test.com;CCadress2@test.com", "Test Subject", "Test <b>Body</b>", "test.au3;test3.au3") ; ; ; ; Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0) $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Cc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $Ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Sent the Message $objEmail.Send if @error then SetError(2) return $oMyRet[1] EndIf EndFunc ;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Jack_10 Posted September 10, 2006 Author Share Posted September 10, 2006 thx man i have tested it and ... when i send 1st all is ok i recieve mial instantly , but when i send 2nd , 3th etc script need about 18 second to end program and there is no error but i dont recieve mails event after 10 min) so version with ipport and ssl dont generate errors but still not all is ok Link to comment Share on other sites More sharing options...
Zedna Posted September 10, 2006 Share Posted September 10, 2006 (edited) Try to make all Configuration.Fields.Item stuff only once (script init) and not at every calling your UDF for sending email.EDIT: also ObjCreate and all what don't changes between emails Edited September 10, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jack_10 Posted September 10, 2006 Author Share Posted September 10, 2006 Try to make all Configuration.Fields.Item stuff only once (script init) and not at every calling your UDF for sending email.EDIT: also ObjCreate and all what don't changes between emailsim still newbe and cant do it rather can u paste some code ? pls Link to comment Share on other sites More sharing options...
Zedna Posted September 10, 2006 Share Posted September 10, 2006 (edited) im still newbe and cant do it rather can u paste some code ? pls Not tested, only quick work. Note: Attachments from previous email must be somehow deleted. expandcollapse popup#include <file.au3> Global $objEmail Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailComInit('mail.gmx.net', "Usernmae", "password") If @error then msgbox(0,"Error initializing CDO.Message","Error code:" & @error & " Description:" & $rc) Exit EndIf $rc = _INetSmtpMailCom("DisplayName", "FROM YourAdress@xxx.xx", "TO YourAdress@xxx.xx", "Test Subject", "Test <b>Body</b>") If @error then msgbox(0,"Error sending message","Error code:" & @error & " Description:" & $rc) EndIf Func _INetSmtpMailComInit($s_SmtpServer, $s_Username = "", $s_Password = "") $objEmail = ObjCreate("CDO.Message") if @error then SetError(2) return $oMyRet[1] EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf $objEmail.Configuration.Fields.Update EndFunc;==>_INetSmtpMailComInit Func _INetSmtpMailCom($s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Cc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) return 0 EndIf Next EndIf $objEmail.Send if @error then SetError(2) return $oMyRet[1] EndIf EndFunc;==>_INetSmtpMailCom ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc;==>MyErrFunc Edited September 10, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jack_10 Posted September 11, 2006 Author Share Posted September 11, 2006 i have tested u code but now i get error how can i can delated previous Attachments? (and do i have to do it if Attachments = "" ) Link to comment Share on other sites More sharing options...
Zedna Posted September 11, 2006 Share Posted September 11, 2006 i have tested u code but now i get error how can i can delated previous Attachments? (and do i have to do it if Attachments = "" )If you have no attachments then you needn't delete anything.But main advice: If you are such newbie as you can't give and customize such scripts then first read something more from AutoIt HelpFile before doing these "complicated" scripts.HelpFile is very precise so it's nice reading Bye Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
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