Page 1 of 1

Outputting textbox.text into html table

Posted: Wed Jul 22, 2020 2:26 am
by IanUoY
Hi there
My form emails information to end users, and I format it as html and use the BodyAsHTML parameter.

For all intents and purposes this works fine. However, my problem arises when I want to include textbox.text within a table. If I save to a variable first and include that, works fine. If I just reference textbox.text, it doesn't.
How do I prevent the extra step?
eg:
$emailBody = $emailBody + "<span style=font-size:10pt><table><tr><td width=100><b>Username:</b></td><td width=750>$username</td></tr></table></style>" ....would work fine
$emailBody = $emailBody + "<span style=font-size:10pt><table><tr><td width=100><b>Username:</b></td><td width=750>$textboxUsername.Text</td></tr></table></style>" ...won't
Regards
Ian

Re: Outputting textbox.text into html table

Posted: Wed Jul 22, 2020 6:55 am
by Alexander Riedel
[Topic moved by moderator]

Re: Outputting textbox.text into html table

Posted: Wed Jul 22, 2020 8:09 am
by jvierra
Fundamental to PowerShell. objects property references (the dotted reference $textbox.text) requier the use of subexpression expansion in a quoted string.

$emailBody += "<span style=font-size:10pt><table><tr><td width=100><b>Username:</b></td><td width=750>$($textboxUsername.Text)</td></tr>"

Re: Outputting textbox.text into html table

Posted: Wed Jul 22, 2020 8:40 am
by IanUoY
Perfect...thank you :)