MrAutomationGuy Posted March 1, 2012 Share Posted March 1, 2012 (edited) Hi,My First thread....Yeah.First I want to thank the AutoIT team for a great job, I have become a fan and I use it on a daily bases.Here is my issue ....I have an AutoIT script, which generate a VBS script, Executes the "RunWait" and Executes that VBS scripts to send an Email to a user. This scripts works on 24 hosts that are 2008, Windows7 but Windows 2003.TIn Windows 2003, If I double click on "C:SendEmail.VBS" in Windows Explorer, it will successfully send the email. However, if I run it with my AutoIT Script(C;SendEmail.Au3), no errors is returned, and no Email is sent either.I have included my autoit and vbs script code in here. any thoughts??The VBS Script:'___________SendEmail.vbs____________________On Error Resume NextSet objShell = Wscript.CreateObject("Wscript.Shell")Dim strEventTextLogFile "Sending an Email Started..........."sendMail "Site Admin<Administrator@site.com>", admin@site.com, "Testing.....blah blah", "Attention, Your Host blah blah...1403"' ----- Success exit ------' WSscript.Quit(0)' ----- Local Subroutines ------'Function sendMail(strFrom, strTo, strSubject, strMail)On Error Resume NextoMailServer = "myex.site.com"Set objEmail = CreateObject("CDO.Message") '<--- I think the issue happens here, doesn't create the CDO object. objEmail.From = strFrom objEmail.To = strTo objEmail.Subject = strSubject objEmail.Textbody = strMail If strMailFile = 1 Then objEmail.AddAttachment strAttachment End If If Err.Number <> 0 Then WScript.StdOut.Write "ERROR: Unable to create CD Object." & vbCrLf & "Error Number [" & Err.Number & "]"& vbCrLf & "Error description: [" & Err.Description & "]" WSscript.Quit(-1) End IfobjEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ oMailServerobjEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _ = 25objEmail.Configuration.Fields.UpdateobjEmail.SendIf Err.Number <> 0 Then WScript.StdOut.Write "ERROR: Unable to send Email." & vbCrLf & "Error Number [" & Err.Number & "]"& vbCrLf & "Error description: [" & Err.Description & "]" WSscript.Quit(-1)Else WScript.StdOut.Write("Sent Email Successfully.") & vbCrLfEnd IfEnd Function'----------------------- End of SendEmail.VBS -------------------The SendEmail.Au3 Global $strTaskScriptPath = "C:TempSendEmail.vbs > C:TempSendEmail.log 2>&1";Execute The VBSLocal $retStr = RunWait(@ComSpec & " /c " & Chr(34) & $strTaskScriptPath& Chr(34), "C:Temp", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)Thanks in advance,MrAutomationGuy; Edited March 1, 2012 by MrAutomationGuy Link to comment Share on other sites More sharing options...
water Posted March 1, 2012 Share Posted March 1, 2012 Why do you use a VBS? AutoIts builtin function _INetSmtpMail should do the same without the need to use RunWait plus return additional error information. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MrAutomationGuy Posted March 2, 2012 Author Share Posted March 2, 2012 (edited) Good Suggestion, I will try it. But how do you send Attachments with INetSmtpMail? Isn't that just a simple SMTP Mail protocal? unless I'm missing something. But my question was mostly on using "RunWait" On 2003. Is there any issues with it? Edited March 2, 2012 by MrAutomationGuy Link to comment Share on other sites More sharing options...
water Posted March 2, 2012 Share Posted March 2, 2012 There is a modified version of INetSmtpMail available that lets you send attachments - I don'tbelieve there is a problem with RunWait on Windows 2003.@SW_SHOW isn't a valid flag according to the docu. $STDERR_CHILD + $STDOUT_CHILD aren't allowed with RunWait - only with Run.Could you please try this modified version?Global $strTaskScriptPath = "C:\Temp\SendEmail.vbs > C:\Temp\SendEmail.log 2>&1" ;Execute The VBS Local $retStr = RunWait(@ComSpec & " /c " & $strTaskScriptPath, "C:\Temp", @SW_MAXIMIZE) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MrAutomationGuy Posted March 2, 2012 Author Share Posted March 2, 2012 (edited) Thank you I got it to work with INetSmtpMail.Question. I found some bugs with INetSmtpMail script and fixed them. I also enhanced how it returns the errors. What's the process of me releasing to the review commuty? Edited March 2, 2012 by MrAutomationGuy Link to comment Share on other sites More sharing options...
water Posted March 2, 2012 Share Posted March 2, 2012 I would open a thread to discuss the issue. I'm not sure if such a thread belongs in the General Help and Support or the Developer Chat forum. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MrAutomationGuy Posted March 2, 2012 Author Share Posted March 2, 2012 Thank Will do. 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