title: PowerShell - sending mail script throwing error
body: <p>Here is the Powershell  Script code i am using</p>
  
  <pre><code>$SmtpClient = New-Object system.net.mail.smtpClient;
  $mailmessage = New-Object system.net.mail.mailmessage;
  $SmtpClient.Host = "exchange server name";
  $SmtpClient.Credentials = New-Object System.Net.NetworkCredential("User name", "password");
  $mailmessage.from = ("user@domain.com");
  $mailmessage.To.add("user@domain.com");
  $mailmessage.Subject = “Message”;
  $mailmessage.Body = “Body”;
  $smtpclient.Send($mailmessage);
  </code></pre>
  
  <p>Here is the error  i am getting</p>
  
  <blockquote>
    <p>Exception calling "Send" with "1" argument(s): "Failure sending mail."
    At C:\Users\user1\Desktop\sendmailPS.ps1:9 char:17
    + $smtpclient.Send &lt;&lt;&lt;&lt; ($mailmessage);
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationExcept     ion
        + FullyQualifiedErrorId : DotNetMethodException</p>
  </blockquote>
  
  <p>Any Help is appreciated and thanks in advance</p>