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

# setPreferredSendingEmailAddress(_:)

Sets the preferred email address to use in the From field, if such an address is available.

## Declaration

```swift
func setPreferredSendingEmailAddress(_ emailAddress: String)
```

## Parameters

- `emailAddress`: The preferred email address used to send this message.

## Discussion

Discussion If the user doesn’t have an account with a preferred address set up, the default account is used instead. 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

- [setSubject(_:)](messageui/mfmailcomposeviewcontroller/setsubject(_:).md)
- [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)
