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
Possible to provide line space in comments?
-
- Posts: 132
- Joined: Thu Oct 23, 2014 10:15 pm
- OLAP Product: tm1, cognos bi
- Version: 10.2
- Excel Version: 2010
Re: Possible to provide line space in comments?
You can add another option called BodyAsHtml, and then you can include HTML Tags on the Email Bodyvino1493 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
sPsCmd = '"& {
Send-MailMessage
-From ' | sFrom | '
-To ' | sTo | '
-Subject ' | '\"' | sSubject | '\"
-Body ' | '\"' | sBody | '\"
-BodyAsHtml -SmtpServer ' | sSmtpServer | '
}"';
-
- Posts: 30
- Joined: Tue Mar 14, 2017 12:01 pm
- OLAP Product: cognos tm1
- Version: 10.2.2
- Excel Version: excel 2013
Re: Possible to provide line space in comments?
Yeah that function will help, thank you so much for bringing it up.
-
- Posts: 30
- Joined: Tue Mar 14, 2017 12:01 pm
- OLAP Product: cognos tm1
- Version: 10.2.2
- Excel Version: excel 2013
Re: Possible to provide line space in comments?
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 );
Last edited by vino1493 on Thu Feb 21, 2019 5:10 pm, edited 1 time in total.
- macsir
- MVP
- Posts: 785
- Joined: Wed May 30, 2012 6:50 am
- OLAP Product: TM1
- Version: PAL 2.0.9
- Excel Version: Office 365
- Contact:
Re: Possible to provide line space in comments?
I am using Powershell as well but I wrap the send email function to sendemail.ps1 file to accept parameters from TI processes.
-
- Posts: 4
- Joined: Wed Apr 04, 2018 10:21 am
- OLAP Product: HOLAP
- Version: 8.1
- Excel Version: 2017
Re: Possible to provide line space in comments?
Yeah, I was looking for an explanation, thanks)