Jump to content

Extract text from a file from a certain point to the end


cahonis

Recommended Posts

Hi all!I'm having problems finding the correct code to use to extract ALL the text after a certain point in a log file.I found some code that will extract the line of after a certain text:

for each strKeyWord in arrKeyWords				If InStr(1, strLine, strKeyWord, vbTextCompare) > 0 Then					strEmailBody = strEmailBody & strLine & vbCrLf				End If			Next

What I need is for the script to grab all the text from a certain point onwards to embed in an email. The entire file gets attached but the end of the file contains a summary which I would like placed in the body of the email.Here is the email routine I currently have:

Set objFile = objFSO.OpenTextFile(strDestFolder & objRegEx.Pattern & pubDate &".txt", 2, False, -1)objFile.Write strNewContentsobjFile.CloseSet objEmail = CreateObject("CDO.Message")sAttachments= strDestFolder & objRegEx.Pattern & pubDate &".txt"aAttachment = Split(sAttachments, ",", -1, 1)arrKeyWords = ("COPY SUMMARY")objEmail.From = "tapecopy@domain.com"objEmail.To = "user@domain.com"		If objFSO.GetFolder(strDestFolder).Files.Count >0 Then		objEmail.Subject = "Tape Copy Log for"& objRegEx.Pattern		'objEmail.Textbody = "Please find attached the tapecopy log for"& objRegEx.Pattern			for each strKeyWord in arrKeyWords				If InStr(1, strLine, strKeyWord, vbTextCompare) > 0 Then					strEmailBody = strEmailBody & strLine & vbCrLf				End If			Next		for each attachment in aAttachment		objEmail.AddAttachment attachment		next		Else		objEmail.Subject = "Tape Copy failed for"& objRegEx.Pattern		objEmail.Textbody = "Tapecopy job for"& objRegEx.Pattern &"has failed, please investigate."		End IfobjEmail.Configuration.Fields.Item _	("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2objEmail.Configuration.Fields.Item _	("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _		"smtpmail.closepf.local" objEmail.Configuration.Fields.Item _	("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25objEmail.Configuration.Fields.UpdateobjEmail.Send

This will take the line of text after the search string but I want ALL the text from the search string until the end of the file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...