title: Powershell email add CC field
body: <p>I found this code here for sending emails and attachments with Powershell and works great for that but I'm trying to add the email CC to it. I can't figure it out. Please give me a hand if you can. I tried various ways of adding $message.Cc.Add("email_address"); but can't get it working.  Thank you.</p>
  
  <pre><code>$Username = "MyUserName";
  $Password = "MyPassword";
  $path = "C:\attachment.txt";
  
  function Send-ToEmail([string]$email, [string]$attachmentpath){
  
      $message = new-object Net.Mail.MailMessage;
      $message.From = "YourName@gmail.com";
      $message.To.Add($email);
      $message.Subject = "subject text here...";
      $message.Body = "body text here...";
      $attachment = New-Object Net.Mail.Attachment($attachmentpath);
      $message.Attachments.Add($attachment);
  
      $smtp = new-object Net.Mail.SmtpClient("smtp.gmail.com", "587");
      $smtp.EnableSSL = $true;
      $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
      $smtp.send($message);
      write-host "Mail Sent" ; 
      $attachment.Dispose();
   }
  Send-ToEmail  -email "reciever@gmail.com" -attachmentpath $path;
  </code></pre>