Page 1 of 1
Possible to provide line space in comments?
Posted: Wed Mar 28, 2018 2:40 pm
by vino1493
I'm trying to send to email notification using powershell. For the email's body I wish to add line space to look something like below
Hi All,
Load has completed.
My current code is
sSubject = ' load completed' ;
sBody = ' load completed';
# build powershell command
sPsCmd = '"& {
Send-MailMessage
-From ' | sFrom | '
-To ' | sTo | '
-cc ' | sCC | '
-Subject ' | '\"' | sSubject | '\"
-Body ' | '\"' | sBody | '\"
-SmtpServer ' | sSmtpServer | '
}"';
# execute command
ExecuteCommand ( 'powershell.exe -command ' | sPsCmd, 1 );
Is it possible to add line space to email's 'sBody' part?
Many space bars can be added as a workaround but this there a right way to do it?
Note:I didn't share few variable in the above code please ignore those
Re: Possible to provide line space in comments?
Posted: Wed Mar 28, 2018 2:52 pm
by tm123
vino1493 wrote: ↑Wed Mar 28, 2018 2:40 pm
I'm trying to send to email notification using powershell. For the email's body I wish to add line space to look something like below
Hi All,
Load has completed.
My current code is
sSubject = ' load completed' ;
sBody = ' load completed';
# build powershell command
sPsCmd = '"& {
Send-MailMessage
-From ' | sFrom | '
-To ' | sTo | '
-cc ' | sCC | '
-Subject ' | '\"' | sSubject | '\"
-Body ' | '\"' | sBody | '\"
-SmtpServer ' | sSmtpServer | '
}"';
# execute command
ExecuteCommand ( 'powershell.exe -command ' | sPsCmd, 1 );
Is it possible to add line space to email's 'sBody' part?
Many space bars can be added as a workaround but this there a right way to do it?
Note:I didn't share few variable in the above code please ignore those
You can add another option called BodyAsHtml, and then you can include HTML Tags on the Email Body
sPsCmd = '"& {
Send-MailMessage
-From ' | sFrom | '
-To ' | sTo | '
-Subject ' | '\"' | sSubject | '\"
-Body ' | '\"' | sBody | '\"
-BodyAsHtml -SmtpServer ' | sSmtpServer | '
}"';
Re: Possible to provide line space in comments?
Posted: Wed Mar 28, 2018 2:56 pm
by vino1493
Yeah that function will help, thank you so much for bringing it up.
Re: Possible to provide line space in comments?
Posted: Wed Mar 28, 2018 4:07 pm
by vino1493
Developed the below code and it is working as expected!
Code: Select all
sSubject = 'WD-' | vDay | ' load completed ' ;
sBody = '
<body>
Hi All,
<br>
<br>
</body>' | 'load started ';
# build powershell command
sPsCmd = '"& {
Send-MailMessage
-From ' | sFrom | '
-To ' | sTo | '
-cc ' | sCC | '
-Subject ' | '\"' | sSubject | '\"
-Body ' | '\"' | sBody | '\"
-BodyAsHtml -SmtpServer ' | sSmtpServer | '
}"';
# execute command
ExecuteCommand ( 'powershell.exe -command ' | sPsCmd, 1 );
Re: Possible to provide line space in comments?
Posted: Wed Mar 28, 2018 9:22 pm
by macsir
I am using Powershell as well but I wrap the send email function to sendemail.ps1 file to accept parameters from TI processes.
Re: Possible to provide line space in comments?
Posted: Thu Apr 05, 2018 8:16 am
by Sophie Kay
Yeah, I was looking for an explanation, thanks)