Don’t do that: Too many parameters in one line is hard to read and to debug:
|
Send-MailMessage -From 'sender@domain.com' -To 'recipient01@domain.com' -Bcc 'recipient02@domain.com' -Subject 'Meeting' -Body 'Please find the attached file' -Attachments 'C:\plannings\meeting.xls' -DeliveryNotificationOption OnFailure, OnSuccess -SmtpServer smtp.domain.com -Credential $credentials |
Another “bad” way to is by using backticks (` escape character in Powershell) because it is hard to see and also because a whitespace after a backtick will return an error.
|
Send-MailMessage -From 'sender@domain.com'` -To 'recipient01@domain.com'` -Bcc 'recipient02@domain.com'` -Subject 'Meeting'` -Body 'Please find the attached file'` -Attachments 'C:\plannings\meeting.xls'` -DeliveryNotificationOption 'OnFailure,OnSuccess'` -Priority 'High'` -SmtpServer 'smtp.domain.com'` -Credential $credentials |
Do that: My favourite way is to use… Read More »