18.3. Configuring Recipients

Our current solution has the limitation of being able to send the message to only one recipient. Of course, we can loop or pipe a collection through ForEach-Object and call the script multiple times, but that is quite inefficient, as it would always open a new connection to the server, send the mail, and then close it just to open it back on the next iteration. Performance is not the only problem: there is no way for us to set up a CC or BCC list for our carbon copy recipients. In addition, we often want to use a friendly name for our recipients, so that users see a real name like "Mike Smith | ACME Corp." instead of a plain "msmith@acme.com."

Adding multiple recipients requires that we pass a collection of addresses ...

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.