Snax Posted January 17, 2007 Posted January 17, 2007 (edited) I am trying to send an email (using the _InetSmtpMailCom function) with a text file attachment which is a log file I am compiling during the running of my script. My first version of my script used 1 standard log file. It was appended to every time I ran my script. Everything worked fine in terms of emailing the attachment. Then I decided I wanted to have a new log file every time the script ran so I started doing the following: ; Assign date/timestamp $date_time = @MON&@MDAY&@YEAR & "-" & @HOUR&@MIN&@SEC ; Assign report name/path to variable $log_file = "N:\AutoIT\logfiles\report_log_"&$date_time&".txt" ; Create 0 byte flat file $log = FileWrite($log_file, "") ; Open flat file for writing $report_log = FileOpen($log_file, 1) At the end of the script I: FileClose($log_file) $email_res = _SMTPEmail($log_file) However, I get an error message stating that the process cannot access the file because it is being used by another process. Again, this didn't happen when I was just opening the same file every time to append the new log data to. Any ideas why this may be getting stuck like this? Apparently, it's my script that is locking the file because I wrote a little test script to do nothing but send that same file and it work fine: #Include <email_func.au3> $email_res2 = _SMTPEmail("N:\AutoIT\logfiles\report_log_01172007-114308.txt") Edited January 17, 2007 by Snax
Developers Jos Posted January 17, 2007 Developers Posted January 17, 2007 $log_file = "N:\AutoIT\logfiles\report_log_"&$date_time&".txt"; Create 0 byte flat file$log = FileWrite($log_file, ""); Open flat file for writing$report_log = FileOpen($log_file, 1)At the end of the script I: FileClose($log_file)You are not closing the filehandle $report_logthis : FileClose($log_file)should be FileClose($report_log) 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.
Snax Posted January 17, 2007 Author Posted January 17, 2007 Egad! Thanks a bunch, that was it! Sometimes it just take a set of new eyes.
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