roflmao Posted May 12, 2007 Share Posted May 12, 2007 Hi i use a _INetSmtpMail script i got of the forum, and i am trying to make a gui for it but i always get an error while sending. I use this script and it works fine #Include<file.au3> Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $s_SmtpServer = InputBox("SMTP©", "Type your SMTP server f.eks smtp.online.no (Googel your isp smtp mail server)") $s_FromName = InputBox("From Name©", "Type the name the mail shuld be from, not mail") ; name from who the email was sent $s_FromAddress = InputBox("From Email©", "Type the email it shal be sent from") ; address from where the mail should come $s_ToAddress = InputBox("To Address©", "Who to send email to") ; destination address of the email - REQUIRED $s_Subject = InputBox("Subject©", "Subject of the mail") ; subject from the email - can be anything you want it to be $as_Body = InputBox("Text©", "Text in the mail") ; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = InputBox("Attach File©", "A file you want to send, leave blank if non") ; the file you want to attach- leave blank if not needed $s_CcAddress = "" ; address for cc - leave blank if not needed $s_BccAddress = "" ; address for bcc - leave blank if not needed $s_Username = "" ; username for the account used from where the mail gets sent - REQUIRED $s_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($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message©", "Error code:" & @error & " Description:" & $rc) Else MsgBox(0, "Sucsess!©", "Mail Sent") 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 = "",$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 And this is my gui and i get an error when sending #include <GUIConstants.au3> #include <INet.au3> GUISetIcon ("Untitled-1.ico") GUICreate("Fake SMTP Mailer") GUISetState (@SW_SHOW) $s_SmtpServer = GUICtrlCreateInput ("Smtp Server (smtp.myisp.com)", 10, 10, 300, 20) $s_FromName = GUICtrlCreateInput ("From Name (John Smith)", 10, 35, 300, 20) $s_FromAddress = GUICtrlCreateInput ("From Address (Johnsmith@email.com)", 10, 60, 300, 20) $s_ToAddress = GUICtrlCreateInput ("To Address (address@email.com)", 10, 85, 300, 20) $s_Subject = GUICtrlCreateInput ("Subject", 10, 110, 300, 20) $as_Body = GUICtrlCreateInput ("Body/Text", 10, 135, 300, 200) $Button_Send = GUICtrlCreateButton ("Send!", 315, 310, 80) GUICtrlCreateProgress(10, 344, 385) While 1 $msg = GUIGetMsg() Select Case $msg = $Button_Send _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) If @error Then MsgBox(0, "Error sending message©", "Error code:" & @error) Else MsgBox(0, "Sucsess!©", "Mail Sent") EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd I get a error code 3.. Link to comment Share on other sites More sharing options...
BrettF Posted May 12, 2007 Share Posted May 12, 2007 Hi i use a _INetSmtpMail script i got of the forum, and i am trying to make a gui for it but i always get an error while sending. I use this script and it works fine And this is my gui and i get an error when sending I get a error code 3..Your have to read the inputs first GUICtrlRead ($control)oÝ÷ Ù:òr§ëaÉb殶sbôæWE6×GÖÂb33c·5õ6×G6W'fW"Âb33c·5ôg&öÔæÖRÂb33c·5ôg&öÔFG&W72Âb33c·5õFôFG&W72Âb33c·5õ7V&¦V7BÂb33c¶5ô&öG Hope it helps Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
roflmao Posted May 13, 2007 Author Share Posted May 13, 2007 thx, now i know that but i dont get any text in the mail.. everything else works Link to comment Share on other sites More sharing options...
roflmao Posted May 13, 2007 Author Share Posted May 13, 2007 nvm, figured it out. thx for the help Link to comment Share on other sites More sharing options...
wysocki Posted November 8, 2018 Share Posted November 8, 2018 (edited) Sorry for opening this ancient thread, but I have an old AutoIT app that I'd like to tweak a bit that includes this function. It works fine, but I'd like to be able to set the REPLY-TO header in the outgoing message. I've looked at the MS cdo/configuration pages but although I see reference to "reply-to", I'm not savvy enough to figure out how to incorporate that into the _InetSmtpMailCom function. EDIT: SOLVED! I dug deep into the CDO.message docs and somehow figured out the right syntax! Simplest mod is to just go into the function and after the line that says $objEmail.To = $s_ToAddress Insert this line: $objEmail.ReplyTo = "joe@somedomain.com" You could get fancy and make it a parameter for the function if you plan to reuse it! Edited November 8, 2018 by wysocki Found answer by experimenting! 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