---
title: "addAttachmentURL(_:withAlternateFilename:)"
framework: messageui
role: symbol
role_heading: Instance Method
path: "messageui/mfmessagecomposeviewcontroller/addattachmenturl(_:withalternatefilename:)"
---

# addAttachmentURL(_:withAlternateFilename:)

Attaches a specified file to the message.

## Declaration

```swift
func addAttachmentURL(_ attachmentURL: URL, withAlternateFilename alternateFilename: String?) -> Bool
```

## Parameters

- `attachmentURL`: The file URL for the attachment. Must not be nil.
- `alternateFilename`: If you supply a string here, the message UI uses it for the attachment. Use an alternate filename to better describe the attachment or to make the name more readable. OK to use a nil value, in which case the attachment’s actual filename is displayed in the message UI.

## Return Value

Return Value true if the attachment at the specified URL was successfully added to the message, or false otherwise.

## Discussion

Discussion You can add zero or more attachments to a message before you display the message to the user. To access information about a message’s attachments, access the attachments property.

## See Also

### Managing attachments

- [disableUserAttachments()](messageui/mfmessagecomposeviewcontroller/disableuserattachments().md)
- [attachments](messageui/mfmessagecomposeviewcontroller/attachments.md)
- [addAttachmentData(_:typeIdentifier:filename:)](messageui/mfmessagecomposeviewcontroller/addattachmentdata(_:typeidentifier:filename:).md)
- [MFMessageComposeViewControllerAttachmentURL](messageui/mfmessagecomposeviewcontrollerattachmenturl.md)
- [MFMessageComposeViewControllerAttachmentAlternateFilename](messageui/mfmessagecomposeviewcontrollerattachmentalternatefilename.md)
- [insertCollaborationItemProvider(_:)](messageui/mfmessagecomposeviewcontroller/insertcollaborationitemprovider(_:).md)
