Solved

Parsing data from log file to email body

Posted on 2014-10-31
7
84 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 46

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 46

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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 46

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 46

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 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