trung0407 Posted November 4, 2008 Share Posted November 4, 2008 This function not work, why no one fix it? I tried to send a message to my Yahoo inbox but not work #include <INet.au3> $s_SmtpServer = "smtp.mail.yahoo.com" $s_FromName = "My Name" $s_FromAddress = "email@yahoo.com" $s_ToAddress = "myemail@yahoo.com" $s_Subject = "My Test UDF" Dim $as_Body[2] $as_Body[0] = "Testing the new email udf" $as_Body[1] = "Second Line" $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) $err = @error If $Response = 1 Then MsgBox(0, "Success!", "Mail sent") Else MsgBox(0, "Error!", "Mail failed with error code " & $err) EndIf Link to comment Share on other sites More sharing options...
SoulA Posted November 4, 2008 Share Posted November 4, 2008 I believe you have to use HTTPS if you are using yahoo. Look at this thread Link to comment Share on other sites More sharing options...
trancexx Posted November 4, 2008 Share Posted November 4, 2008 This function not work, why no one fix it? This is based on that code you posted or what? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
trung0407 Posted November 4, 2008 Author Share Posted November 4, 2008 (edited) No but i took it from the example library. It's not very different. #include <INet.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 $as_Body[2] $as_Body[0] = "Testing the new email udf" $as_Body[1] = "Second Line" $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) $err = @error If $Response = 1 Then MsgBox(0, "Success!", "Mail sent") Else MsgBox(0, "Error!", "Mail failed with error code " & $err) EndIf I believe you have to use HTTPS if you are using yahoo. Look at this threadIt doesnt work either. expandcollapse popup#Include<file.au3> ;################################## ; Variables ;################################## $SmtpServer = "smtp.live.com" ; address for the smtp-server to use - REQUIRED $FromName = "trung0407" ; name from who the email was sent $FromAddress = "****@hotmail.com"; address from where the mail should come $ToAddress = "****@yahoo.com" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "test" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file you want to attach- leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "****@hotmail.com" ; username for the account used from where the mail gets sent - REQUIRED $Password = "****" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $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.Bcc = $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]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF);### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) 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 If Number($IPPort) = 0 then $IPPort = 25 $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 ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" 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 P.S: i just censor my email and pass If you could give me a working SMTP autoit program, i'd be grateful Edited November 4, 2008 by trung0407 Link to comment Share on other sites More sharing options...
Fanatick Posted November 4, 2008 Share Posted November 4, 2008 $Username = "****@hotmail.com" ; username for the account used from where the mail gets sent - REQUIRED In the second code at this line Username = not the email adresse. For example if your adress is blabla@hotmail.com It will be : $Username = "blabla" ; username for the account used from where the mail gets sent - REQUIRED And try with gmail , I'm not sure that it work with yahoo and msn , I use gmail and its work Link to comment Share on other sites More sharing options...
trung0407 Posted November 4, 2008 Author Share Posted November 4, 2008 but with Windows Live, there is a lot of choice email@hotmail.com email@hotmail.fr email@live.com They are different accounts. If you just give email, there server won't know which username you are talking about. Link to comment Share on other sites More sharing options...
trancexx Posted November 4, 2008 Share Posted November 4, 2008 I see only problems caused by you, not by _INetSmtpMail(). You should really learn at least something about this protocol (SMTP) before stating that from the first post. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2008 Developers Share Posted November 4, 2008 (edited) I see only problems caused by you, not by _INetSmtpMail().You should really learn at least something about this protocol (SMTP) before stating that from the first post.Correct.@OPTry setup your OutLook express (or any other email client) to work with the SMTP server you used in the initial post and tell us if it works or not.To use GMail or any other authenticated SMTP service you could try using _InetSmtpMailCom() I posted in teh examples forum.Jos Edited November 4, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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