Hi,
Try using the script below - it gets information displayed in the 'Log Items' pane of the 'Test Log' panel and posts it to the log along with the status of each log entry. The result that is returned by the GetLogItems() function can be also passed to the SendMail function's Body parameter.
Sub Test()
Call Log.Message("Current log items", GetLogItems())
' Call SendMail(<ToAddress>, <FromHost>, <FromName>, <FromAddress>, <Subject>, GetLogItems())
End Sub
Function GetLogItems()
Dim tempFolder, xDoc, result
tempFolder = aqEnvironment.GetEnvironmentVariable("temp") & "\" &_
GetTickCount() & "\"
If 0 <> aqFileSystem.CreateFolder(tempFolder) Then
Log.Error("The " & tempFolder & " temp folder was not created")
GetLogItems = ""
Exit Function
End If
If Not Log.SaveResultsAs(tempFolder, lsHTML) Then
Log.Error("Log was not exported to the " & tempFolder & " temp folder")
GetLogItems = ""
Exit Function
End If
Set xDoc = Sys.OleObject("MSXML2.DOMDocument.4.0")
xDoc.load(tempFolder & "root.xml")
result = LogDataToText(xDoc.childNodes.item(1), 0, " ")
Call aqFileSystem.DeleteFolder(tempFolder, True)
GetLogItems = result
End Function
Function LogDataToText(logData, indentIndex, indentSymbol)
Dim i, result
If "LogData" <> logData.nodeName Then
LogDataToText = ""
Exit Function
End If
result = ""
For i = 0 To indentIndex - 1
result = result & indentSymbol
Next
result = result & "Name: " & logData.getAttribute("name") & ", status: " &_
GetTextOfStatus(logData.getAttribute("status")) & vbCrLf
For i = 0 To logData.childNodes.length - 1
result = result & LogDataToText(logData.childNodes.item(i), indentIndex + 1,_
indentSymbol)
Next
LogDataToText = result
End Function
Function GetTextOfStatus(statusIndex)
Select Case statusIndex
Case "0" GetTextOfStatus = "OK"
Case "1" GetTextOfStatus = "WARNING"
Case "2" GetTextOfStatus = "FAILED"
Case Else GetTextOfStatus = "UNDEFINED"
End Select
End Function