18.4. Working with Message Headers

Frequently, we need to set our message with additional headers that will signal the priority, Reply-To address, and many other things that we, our mail client, or our mail server can recognize, such as a request for sending back a message read notification. The message priority and Reply-To address are conveniently exposed as properties of the MailMessage class:

$message.Priority = [System.Net.Mail.MailPriority] "High"
$message.ReplyTo = test2@deshev.com

To accommodate setting those properties in our script, we need to add two more parameters: $priority and $replyTo. They default to $null and an empty string respectively, and we need to add some checks to skip configuring them if the parameters have not been ...

Get Pro Windows PowerShell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.