O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required