title: sending email with SwiftUI
body: <p>I'm trying to implement sending email feature into my mini app.</p>
  <p>Here's the code I'm using (took it from <a href="https://hackingwithswift.com" rel="nofollow noreferrer">https://hackingwithswift.com</a>):</p>
  <pre><code>import Foundation
  import SwiftUI
  import MessageUI
  
  func sendEmail() {
      if MFMailComposeViewController.canSendMail() {
          let mail = MFMailComposeViewController()
          mail.mailComposeDelegate = self
          mail.setToRecipients([&quot;you@yoursite.com&quot;])
          mail.setMessageBody(&quot;&lt;p&gt;You're so awesome!&lt;/p&gt;&quot;, isHTML: true)
  
          present(mail, animated: true)
      } else {
          // show failure alert
      }
  }
  
  func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
      controller.dismiss(animated: true)
  }
  </code></pre>
  <p>When running my code, I get these 2 errors:</p>
  <p><code>Cannot find self in scope</code></p>
  <p><code>Cannot find present in scope</code></p>
  <p>How can I fix it?</p>