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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.