My Account   Contact Us    
  
» HomeProductsSupportDeveloper CommunityCompany
Code to Copy ActivMail 1.3 log file to a database

Reads the file and parses it into an SQL query


Code to Copy an ActivMail 1.3 log file to a database:

<cffile action="READ" file="c:your_log_file.log" variable="File">
 
<!--- find the first line of the file
 skip the comments
 --->
<cfset pos1 = Find("""", file)>
<cfset file = Right(file, Len(file)-pos1+1)>
 
<!--- loop through each line of the file --->
<cfloop list="#file#" delimiters="#Chr(13)#" index="line">
 <!--- remove any extra line feeds --->
  <cfset line = Replace(line, Chr(10), "", "ALL")>
 
 <!--- replace " with ' --->
 <cfset line = Replace(line, """", "'", "ALL")>
 <cfset line = Trim(line)>
 
 <!--- add to the db --->
 <cfif ListLen(line) IS 11>
  <cfquery datasource="your_datasource">
   INSERT INTO logfile(DateTime,Mode,Status,MailServer,MessageID,[To],QueueTime,ErrorType,LastCommand,ErrorMsg,QueryRowNumber)
   VALUES (#PreserveSingleQuotes(line)#)
  </cfquery>
 </cfif>
 </cfloop>

Search Knowledge Base:
Sign up for our newsletter: | Subscribe with RSS: RSS
© ActivSoftware 1999 to 2005 | Privacy Statement