<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MailKit",
  "identifier" : "/documentation/MailKit/MEComposeSessionHandler/viewController(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MailKit"
    ],
    "preciseIdentifier" : "c:objc(pl)MEComposeSessionHandler(im)viewControllerForSession:"
  },
  "title" : "viewController(for:)"
}
-->

# viewController(for:)

Provides a custom view controller to display as part of the compose window.

```
func viewController(for session: MEComposeSession) -> MEExtensionViewController
```

## Parameters

`session`

The session that represents the properties of the message in the compose window.

## Return Value

A custom [`MEExtensionViewController`](/documentation/MailKit/MEExtensionViewController) subclass that Mail displays in the compose window.

## Discussion

To configure an icon and tooltip for the compose session handler’s view controller, add the following entries to your extension’s `Info.plist` file:

```plist
<key>NSExtensionAttributes</key>
<dict>
    <key>MEComposeSession</key>
    <dict>
        <key>MEComposeIcon</key>
        <string>YourCustomComposeIconName</string>
        <key>MEComposeIconToolTip</key>
        <string>Tooltip for the compose session handler.</string>
    </dict>
<dict>
```

Include an icon in your extension’s bundle using the name you specify for <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSExtension/NSExtensionAttributes/MEComposeSession/MEComposeIcon>.

> Tip:
> Include the icon in an asset catalog in your extension’s bundle, and include both light and dark variants.

---

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)