---
title: "setSubject(_:)"
framework: Message UI
role: symbol
role_heading: Instance Method
platforms: [iOS 3.0+, iPadOS 3.0+, Mac Catalyst 13.1+, visionOS 1.0+]
path: "messageui/mfmailcomposeviewcontroller/setsubject(_:)"
---

# setSubject(_:)

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

## Declaration

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

## Parameters

- `subject`: The text to display in the subject line.

## Discussion

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.

## See Also

### Setting mail fields programmatically

- [setToRecipients(_:)](messageui/mfmailcomposeviewcontroller/settorecipients(_:).md)
- [setCcRecipients(_:)](messageui/mfmailcomposeviewcontroller/setccrecipients(_:).md)
- [setBccRecipients(_:)](messageui/mfmailcomposeviewcontroller/setbccrecipients(_:).md)
- [setMessageBody(_:isHTML:)](messageui/mfmailcomposeviewcontroller/setmessagebody(_:ishtml:).md)
- [addAttachmentData(_:mimeType:fileName:)](messageui/mfmailcomposeviewcontroller/addattachmentdata(_:mimetype:filename:).md)
- [setPreferredSendingEmailAddress(_:)](messageui/mfmailcomposeviewcontroller/setpreferredsendingemailaddress(_:).md)
