Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parsing data from log file to email body

Posted on 2014-10-31
7
Medium Priority
?
100 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
6 Comments
 
LVL 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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 49

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 49

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

824 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