How to send an email to a UNIQUE group of recipients with contents based on CSV
<p>I'm not exactly sure how to phrase this question so that it makes sense.
I have a CSV that contains User, Manager and Manager Email Address. The Manager and Manager email address columns will contain duplicates, but are sorted. See the below image.</p>

<p><a href="https://i.stack.imgur.com/d3WEc.png" rel="nofollow"><img src="https://i.stack.imgur.com/d3WEc.png" alt="enter image description here"></a></p>

<p>I want to send an email to the manager with the contents and recipient being dynamically based upon the CSV. </p>

<pre><code>$Outlook = New-Object -comObject Outlook.Application 
         $Mail = $Outlook.CreateItem(0) 
         $Mail.Recipients.Add("sally@x.com")
         $Mail.Subject = "People" 
         $Mail.Body = "Bob, John, Joe"
         $Mail.Send()
</code></pre>

<p>That's not a problem, I understand that. What I need to know how to do is make it so that only one email is sent per manager.</p>

<p>For example, Email 1 would be sent to Sally@x.com and the contents would be Bob, John, Joe. Email 2 would be sent to Brian@x.com with the contents Joe. Email 3 would be sent to Joey@x.com with the contents Ally, Alex. </p>

<p>What I can't have is one email sent to the manager per user. In other words, Sally receiving 3 emails, Joey receiving 2. </p>

<p>I can't even figure out where to start with this. I feel like because it's sorted, I should be able to do a foreach unique managermail in the list... </p>

<p>Any help would be greatly appreciated. </p>