title: Send-Mailmessage timing out
body: <p>I am looking to improve an old batch script and upgrade it to powershell, this is a robocopy batch script and i would like it to send a mail with the logfile attatched when it is finished. i managed to get the drive mappings and robocopy part sorted but im having some issues getting the send-mailmessage part to work</p>
  
  <pre><code>`$SourceFolder = "V:\"
  $DestinationFolder = "Y:\"
  $Dateandtime = Get-Date -format filedate
  $password = XXXXXXXXX
  $Subject = "Robocopy Results: Backup USA - NL"
  $SMTPServer = "mailserver.domain.com"
  $Sender = "backupusr@domain.com"
  $Username = "backupusr"
  $Recipients = "administrator@domain.com"
  $Admin = "administrator@domain.com"
  $SendEmail = $True
  $IncludeAdmin = $True
  $AsAttachment = $False
  $Cred =  new-object Management.Automation.PSCredential $Username, ($password 
  | ConvertTo-SecureString -AsPlainText -Force)`
  </code></pre>
  
  <p>This is the line that causes the script to timeout</p>
  
  <pre><code>Send-MailMessage -SmtpServer $SMTPServer -From $Sender -To $Recipients -Subject $Subject -Body "Robocopy results are attached." -DeliveryNotificationOption onFailure -UseSsl -Credential $Cred
  </code></pre>
  
  <p>this is the error i recieve</p>
  
  <blockquote>
    <p>Send-MailMessage : The operation has timed out.
    At C:\Scripts\bpcti-robocopy.ps1:113 char:1
    + Send-MailMessage -SmtpServer $SMTPServer -From $Sender -To $Recipient ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
        + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage</p>
  </blockquote>
  
  <p>Any help would be greatly appreciated.</p>