I'm trying to get a row of a table from a Webpage and fill the HTML Code into an HTML E-Mail. I'm using Powershell for this.
$ie = New-Object -com InternetExplorer.Application
$ie.visible = $false
$ie.navigate(www.example.com)
$htmlDetailedRow = $ie.document.documentElement.getElementsByClassName("className")
Above you see how I get the element that I want to display in my E-Mail.
$body = @"
<html>
<body>
<div class="background">
<table>
$htmlDetailedRow
</table>
</div>
</body>
</html>
"@
Above you see my HTML for the Email.
<tr class="className">
<td colspan="5" style="border-top: 0; border-bottom: 0; padding: 0">
<table class="clean" style="margin: 5px 0 0 0; width: 100%">
<tbody>
<tr>
<td style="text-align: left; width: 25%"><i>Date</i></td>
</tr>
<tr>
<td style="text-align: left; width: 25%">22.03.2022</td>
<td style="text-align: left; width: 30%">Text</td>
<td style="text-align: left; width: 15%">1</td>
<td style="text-align: left; width: 15%">5.136</td>
</tr>
</tbody>
</table>
</td>
</tr>
Above you can see the row I want to grab from the Webpage. My idea is to take the row and insert into a table in my Email HTML. The Webpage is behind a Login so unfortunately I can't link to the Page.
The HTML is working fine but the $htmlDetailedRow wont display right. Instead it displays "mshtml.HTMLTableRowClass". I know I have to convert $htmlDetailedRow somehow, but I have no idea how.
I hope someone can help me. Thanks.
I figured it out. Because I was using getElementsByClassName("className"), it returned a array back. So to get to the innerHtml i had to acess like this.
$htmlDetailedRow = $ie.document.documentElement.getElementsByClassName("className")
$htmlDetailedRow[0].innerHTML