Solved

Parsing data from log file to email body

Posted on 2014-10-31
7
78 Views
Last Modified: 2014-12-01
I am sending out automated emails when certain criterian are met. When I do this I am just sending them in the body of the email a copy of all the data in a captured log file. What I want to do is send them just a specific section of the log file. I have attached an example log file and below is the code I am using to format the email.

MailStatus = SP_DO_MAIL_SEND('usernname@ouremail.COM',MailSubject,LogDir||LogFile,);

Open in new window

ExampleLogFile.Log
0
Comment
Question by:jlcannon
  • 4
  • 2
7 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40418496
I don't recognize the code you are using but would a method that opens the log file, finds "Data I want" (I know that it would not be exactly that text) and extracts it to a string help you?

If so there would need to be some sort of delimiter so that the start of the data you want could be recognized.
0
 

Author Comment

by:jlcannon
ID: 40419353
might work. I was hoping for something more like:
SUBSTRING(Input File FROM '&&&' to '%%%');

Open in new window


and I could add those charactors to the input files and it would give me everything between those charactors. Of course I have tried it and I get nothing.
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40419707
It looks like you are trying to use a formula and while my expertise is in VBA rather than formulas, I don't believe there is an Excel SUBSTRING formula. In any case if you are reading the file using VBA and you can make it so the file has delimiters then it's an easy task to extract the data you want.

Given a file that looks like this:
I don't want this part|but I do want this part|but leave this part out of it.

This code will give the middle section.

Dim FF As Integer
Dim strWholeFile As String
Dim strParts() As String

FF = FreeFile
Open "C:/temp/delimited.txt" For Input As FF
strWholeFile = Input$(LOF(FF), FF)
Close

strParts = Split(strWholeFile, "|")

MsgBox strParts(1)

Open in new window

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 45

Expert Comment

by:Martin Liss
ID: 40420368
If the logfile data were in a cell then you could do this. The code assumes the data is in A1 and the part you want winds up in B1.

    Range("A1").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="|", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
        TrailingMinusNumbers:=True

Open in new window

0
 

Author Comment

by:jlcannon
ID: 40421456
I am travelling right now away from my desk so I will definatley give the 2 previous proposed solutions a try when I get back to my project computer.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40473308
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now