Solved

Parsing data from log file to email body

Posted on 2014-10-31
7
85 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 47

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 47

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

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 47

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
Updates not working for MS Windows 7 12 192
Excel Automation VBA 19 102
VB script to continue despite error 2 48
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

740 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