title: Power Shell Script SMTP Email Issues
body: <p>1) How can I store my credentials in this script - it's prompting me for credentials </p>
  
  <p>2) Should the last two lines be at the bottom or before the params? I am getting this error - I think I am not passing my credentials correctly</p>
  
  <blockquote>
    <p>Send-MailMessage : The remote name could not be resolved: 'System.Net.Mail.SmtpClient'
    At line:21 char:1
    + Send-MailMessage @smtpMessage
    Blockquote</p>
  </blockquote>
  
  <pre><code>    param (
      [string]$Path = "C:\Users\me\Desktop\ScanFolder",
      $From = "me@msn.com",
      $To = "you@msn.com",
      $Subject1 = "Changes Found",
      $Subject2 = "No Changes in last x minutes",
      $Body = "anything",
      $SMTPServer = "smtp.live.com",
      $SMTPPort = "587",
      [PSCredential]$Credential #pass in credential
  )
  $smtpMessage = @{
      To = $To
      From = $From
      Subject = $Subject
      Smtpserver = $SMTPClient
      Credential = $Credential
      BodyAsHtml = $true
  }
  
  Send-MailMessage @smtpMessage
  
  $secpasswd = ConvertTo-SecureString "mypassword" -AsPlainText -Force
  $creds = New-Object System.Management.Automation.PSCredential ("me@msn.com", $secpasswd)
  </code></pre>