dufran3 Posted May 25, 2007 Share Posted May 25, 2007 I have everything coded correctly, as far as I can tell, in my script to send e-mail via SMTP/CDO. I have a script, that creates a GUI, and does a bunch of logging. It logs into 2 text files, that are located in a directory on the local machine. I have logging functions for failed and succesfull install/file checks. If 1 fails, it sets a $FailedFlag Global variable to 1. Then, right before the last line of my script, "Exit", I have an if statement checking that variable. If it == 1 then it calls this _Smtp e-mail function, which I will post below. If I run this exact function, outside of the script, in a seperate script, it runs fine, e-mails me all the info and both attachments. When I run it inside of my script, which is the one that is writing all the logs. the second attachment always fails. I am closing the file beforehand, because I thought it was giving me an error because it was still open...not sure what it could be...any thoughts? The function is below. Again, the first log file, Functions.log always is successfull...I get the following error when it tries to attach the second one... expandcollapse popupFunctions2.3.au3 (2585) : ==> The requested action with this object has failed.: $objMail.AddAttachment ($smtpAttachmentFile2) $objMail.AddAttachment ($smtpAttachmentFile2)^ ERRORoÝ÷ Ø"µ·jë¶W¡jwez+,¶)e¢§jëh×6Func _SmtpEmail() $objMail= ObjCreate("CDO.Message") $Date = _NowDate() $Time = _NowTime() $Attachment = 0 $smtpAttachmentFile1 = 'C:\Temp\RDT\Functions.log' $smtpAttachmentFile2 = 'C:\Temp\RDT\RDTSetup.log' If FileExists($smtpAttachmentFile1) Then $Attachment = '"Functions.log" & ' If FileExists($smtpAttachmentFile2) Then $Attachment &= ' "RDTSetup.log" ' With $objMail .From = "RDTLogs@secrethehehe.com" .To = "rcpt@secrethehehe.com" .Subject = "Rapid Deployment Tool Log Report" .TextBody = "Rapid Deployment Tool Log Report" & @CRLF & @CRLF & _ "Date: " & $Date & @CRLF & _ "Time: " & $Time & @CRLF & _ "User: " & @UserName & @CRLF & _ "Computername: " & @ComputerName & @CRLF & _ "IP Address: " & @IPAddress1 & @CRLF & _ "OSVersion: " & @OSVersion & @CRLF & _ "Service Pack: " & @OSServicepack & @CRLF & _ "Attachment(s): " & $Attachment EndWith If FileExists($smtpAttachmentFile1) Then ;$objMail.AddAttachment ($smtpAttachmentFile1) EndIf If FileExists($smtpAttachmentFile2) Then FileClose($smtpAttachmentFile2) $objmail.AddAttachment ($smtpAttachmentFile2) EndIf With $objMail .Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "exchange1" .Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Configuration.Fields.Update .Send() EndWith $objMail = 0 EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 (edited) Fileclose is never done with the filename but you need to use the file hanlde. Also add the Comm error handler to figure out what the error is: Look for _INetSmtpMailCom() for an implementation of the cdo messaging in AUtoIt3. Edited May 25, 2007 by JdeB 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 that function requires authentication, aka, username and password. Can I take that out of there? and where? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 that function requires authentication, aka, username and password. Can I take that out of there? and where?How did you come to that conclusion ?I think its optional .. 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 (edited) straight from the function $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 dur....guess if $s_username = "" Then it works....the "REQUIRED" got me worried. Nevermind then. Edited May 25, 2007 by dufran3 Link to comment Share on other sites More sharing options...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 getting this when including file.au3 >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "\\fs1\\AutoIt\RDT Project\au3\testing\RDT_2.5.au3" C:\Program Files\AutoIt3\Include\file.au3 (24) : ==> Duplicate function name.: Func _FileCountLines($sFilePath) Link to comment Share on other sites More sharing options...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 anyway....this looks like are really good UDF, but may be more fluff than I need. I was just really hoping someone could help me figure out why that second log file fails to attach to the message every time... Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 (edited) Updated the Comments .... It is optional and only needed for SSL connections like GMAIL... Edited May 25, 2007 by JdeB 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 Cool, thx for that...but do you have any idea why that second log file wont attach? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 Cool, thx for that...but do you have any idea why that second log file wont attach?Have you done as suggested ? - add the Com error handler and see what the true error is ...- close the file properly with the filehandle in stead of filename .. 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 (edited) Sorry, what functions are being used in file.au3 that it needs to be included? Yes, the file is being opened here. GLOBAL $LogFileOpen = FileOpen('C:\Temp\RDT\RDTSetup.log', 1)oÝ÷ Ø!jxuÉh²)àÛhjëh×6 Fileclose($LogFileOpen) Also, I'm not sure how to implement the COM error handler in my function...:-( Edited May 25, 2007 by dufran3 Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 Sorry, what functions are being used in file.au3 that it needs to be included?_PathFull(), but do not understand your problem... just ensure its include only once . 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 aha haha "Error sending message" "Error code:2 Description: The process cannot access the file because it is being used by another process" Any idea how i fix this? I tried using "FileClose" but it doesn't seem to be working. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 (edited) aha haha"Error sending message""Error code:2 Description: The process cannot access the file because it is being used by another process"Any idea how i fix this? I tried using "FileClose" but it doesn't seem to be working.sigh ....How did you close it? I mean did you follow my advice and close it with the handle retuned by FileOpen() ? Edited May 25, 2007 by JdeB 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 Roger that, I opened the log file like this. GLOBAL $LogFileOpen = FileOpen('C:\Temp\RDT\RDTSetup.log', 1) I am closing thisfile inside of my function, which is running after the last file write to this log file. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 I am closing thisfile inside of my function, which is running after the last file write to this log file.Let me put it this way: AutoIt3 is telling you the file isn't close or used by another process at the time it is trying to attach it ... so my guess is that the file isn't closed at the time you try to attach it. 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 (edited) ergg...not good. Is there any other way then just saying "fileclose" ? Or perhaps there is a way to query open file handles? Edited May 25, 2007 by dufran3 Link to comment Share on other sites More sharing options...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 Found it. My logging function was opening and closing the log file each time the function was called. I didn't think that was very good. So I opened the log file at the beginning of the script, and closed it at the end. However, I forgot to delete the open and closes inside of the function. Got rid of those...presto! Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2007 Developers Share Posted May 25, 2007 Found it. My logging function was opening and closing the log file each time the function was called. I didn't think that was very good. So I opened the log file at the beginning of the script, and closed it at the end. However, I forgot to delete the open and closes inside of the function. Got rid of those...presto!Must be getting clearvoiant Let me put it this way: AutoIt3 is telling you the file isn't close or used by another process at the time it is trying to attach it ... so my guess is that the file isn't closed at the time you try to attach it. 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...
dufran3 Posted May 25, 2007 Author Share Posted May 25, 2007 clair·voy·ant having or claiming to have the power of seeing objects or actions beyond the range of natural vision. na...i'm noob still 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