<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MessageUI",
  "identifier" : "/documentation/MessageUI/MFMailComposeViewController/setSubject(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Message UI"
    ],
    "preciseIdentifier" : "c:objc(cs)MFMailComposeViewController(im)setSubject:"
  },
  "title" : "setSubject(_:)"
}
-->

# setSubject(_:)

Sets the initial text for the subject line of the email.

```
func setSubject(_ subject: String)
```

## Parameters

`subject`

The text to display in the subject line.

## Discussion

This method replaces the previous subject text with the new text. Only call this method before you display the mail composition interface. Don’t call it after presenting the interface to the user.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)