title: Sending attachment with MailKit in PowerShell doesn't attach
body: <p>I have a simple script in PowerShell to simply SMTP a PDF attachment. No subject, and no body. The results show the attachment but the email is always received without it. Am I missing something?</p>
  <pre><code>$SMTP = [MailKit.Net.Smtp.SmtpClient]::new()
  $Message = [MimeKit.MimeMessage]::new()
  $Builder = [MimeKit.BodyBuilder]::new()
  
  $Message.From.Add(&quot;myname@mydomain.com&quot;)
  $Message.To.Add(&quot;yourname@yourdomain.com&quot;)
  $Builder.Attachments.Add(&quot;C:\Users\myname\Path\MyPDF.pdf&quot;)
  
  $SMTP.Connect('smtp.xxxx.com', 465, 'SecureSocketOptions.SslOnConnect')
  $SMTP.Authenticate($MAILCREDENTIALS)
  
  $SMTP.Send($Message)
  $SMTP.Disconnect($true)
  $SMTP.Dispose()
  </code></pre>
  <p>Output after sending:</p>
  <pre><code>ContentDuration         : 
  ContentMd5              :
  ContentTransferEncoding : Base64
  FileName                : MyPDF.pdf
  Content                 : MimeKit.MimeContent
  ContentObject           : MimeKit.MimeContent
  Headers                 : {Content-Type: application/pdf; name=&quot;MyPDF.pdf&quot;, Content-Disposition: attachment; filename=&quot;MyPDF.pdf&quot;, Content-Transfer-Encoding: base64}  
  ContentDisposition      : Content-Disposition: attachment; filename=&quot;MyPDF.pdf&quot;
  ContentType             : Content-Type: application/pdf; name=&quot;MyPDF.pdf&quot;
  ContentBase             :
  ContentLocation         :
  ContentId               :
  IsAttachment            : True
  </code></pre>