Question HTMLTable in eMail-body / button for export
Hello,
when I have a lot of lines in the table, all are displayed in the email-body. Is it possible do display only the first 10 line for example and in the -attachself all lines are included?
If i click on the export buttons "excel" or "pdf" in the header "Exported Data" is displayed. The -titletext is set with a variable but it is not displayed.
New-HTML -TitleText $Subject -Online { New-HTMLSection -HeaderText $Subject -HeaderTextColor black -HeaderBackGroundColor limegreen -BorderRadius 15px { New-HTMLPanel -BorderRadius 15px { New-HTMLTable -DataTable $DatenTabelle -PagingLength 10 -HideFooter -ScrollCollapse -FixedHeader -Style cell-border -Buttons excelHtml5, pdfHtml5, pageLength, searchPanes } } }
New-HTMLTable has its own title - so use that. I may need to add the ability to set separate titles per button (as it's possible) and verify why a top-level title is not used if no title is provided (I believe it was used before by the library - but maybe I was wrong).
As for your first question you can roll your own version of it by creating 2 HTML's. One limited in an email... so just do $DataTable | Select-Object -First 10 and then instead of using attach self, create proper HTML with more data. In theory, I could roll it out, but without information to the user that this is not a full table just a glimpse it may be tricky.
My goal is to further limit the email body by removing JS from it (since it's not used) and only attach JS if it's used as part of AttachSelf.
it's little bit complicated to add the code here because looks not very nice, but i try If i understand you correctly, i delete the part -AttachSelf -AttachSelfName $Subject But where to place the second table what should be created??
Email -AttachSelf -AttachSelfName $Subject{
EmailHeader {
EmailFrom -Address $from
EmailTo -Addresses $To
EmailServer -Server $mailserver -Port 587
EmailOptions -Priority Normal -DeliveryNotifications Never
EmailSubject -Subject $Subject
}
EmailBody {
EmailTextBox -FontFamily 'Calibri' -FontSize 17 -TextDecoration underline -Color limegreen -Alignment center {
$BodyText
}
New-HTMLText -LineBreak
EmailTextBox -FontFamily 'Calibri' -FontSize 17 -TextDecoration none -Color red -Alignment left {
'Only the first 10 entries are displayed. For more information open the attachment'
}
New-HTMLText -LineBreak
New-HTML -Online {
New-HTMLSection -HeaderText $Subject -HeaderTextColor black -HeaderBackGroundColor limegreen -BorderRadius 15px {
New-HTMLPanel -BorderRadius 15px {
New-HTMLTable -Title $Subject -PagingLength 10 -HideFooter -ScrollCollapse -FixedHeader -Style cell-border -Buttons excelHtml5, pdfHtml5, pageLength, searchPanes -DataTable $DatenTabelle | Select-Object -First 10
}
}
}
New-HTMLText -LineBreak
EmailTextBox -FontFamily 'Calibri' -FontSize 17 -TextDecoration none -Color limegreen -Alignment left {
'Kind regards,'
'Admin'
}
}
}
Something like this:
New-HTML -Online {
New-HTMLSection -HeaderText $Subject -HeaderTextColor black -HeaderBackGroundColor limegreen -BorderRadius 15px {
New-HTMLPanel -BorderRadius 15px {
New-HTMLTable -Title $Subject -PagingLength 10 -HideFooter -ScrollCollapse -FixedHeader -Style cell-border -Buttons excelHtml5, pdfHtml5, pageLength, searchPanes -DataTable $DatenTabelle | Select-Object -First 10
}
}
} -FilePath $env:TEMP\YourTemporaryFile.html
Email {
EmailHeader {
EmailFrom -Address $from
EmailTo -Addresses $To
EmailServer -Server $mailserver -Port 587
EmailOptions -Priority Normal -DeliveryNotifications Never
EmailSubject -Subject $Subject
EmailAttachment -FilePath $env:TEMP\YourTemporaryFile.html
}
EmailBody {
EmailTextBox -FontFamily 'Calibri' -FontSize 17 -TextDecoration underline -Color limegreen -Alignment center {
$BodyText
}
New-HTMLText -LineBreak
EmailTextBox -FontFamily 'Calibri' -FontSize 17 -TextDecoration none -Color red -Alignment left {
'Only the first 10 entries are displayed. For more information open the attachment'
}
New-HTMLText -LineBreak
EmailTable -DataTable ($DatenTabelle | Select-Object -First 10)
New-HTMLText -LineBreak
EmailTextBox -FontFamily 'Calibri' -FontSize 17 -TextDecoration none -Color limegreen -Alignment left {
'Kind regards,'
'Admin'
}
}
}
I tried this and the 2. table is not attached to the mail. I could see the temp file created on the filesystem but it was not usable. I tried to open it and there come up a error message that the file is not present anymore. It only hat a size of 17kb. the first table in the body was present with the first lines as suspected.