# MailTo

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/net/MailTo.java+class:androidx.core.net.MailTo) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

*** ** * ** ***


```
public final class MailTo
```

<br />

*** ** * ** ***

MailTo URI parser. Replacement for `https://developer.android.com/reference/android/net/MailTo.html`.

This class parses a mailto scheme URI and then can be queried for the parsed parameters. This implements RFC 6068.

*Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your URI with the scheme using lower case letters, and normalize any URIs you receive from outside of Android to ensure the scheme is lower case.*

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#MAILTO_SCHEME() = "mailto:"` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#getBcc()()` Retrieve the BCC address line from the parsed mailto URI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#getBody()()` Retrieve the body line from the parsed mailto URI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#getCc()()` Retrieve the CC address line from the parsed mailto URI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/core/net/MailTo#getHeaders()()` Retrieve all the parsed email headers from the mailto URI |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#getSubject()()` Retrieve the subject line from the parsed mailto URI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#getTo()()` Retrieve the To address line from the parsed mailto URI. |
| `static boolean` | `https://developer.android.com/reference/androidx/core/net/MailTo#isMailTo(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html uri)` Test to see if the given string is a mailto URI |
| `static boolean` | `https://developer.android.com/reference/androidx/core/net/MailTo#isMailTo(android.net.Uri)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html uri)` Test to see if the given Uri is a mailto URI |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/net/MailTo` | `https://developer.android.com/reference/androidx/core/net/MailTo#parse(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html uri)` Parse and decode a mailto scheme string. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/net/MailTo` | `https://developer.android.com/reference/androidx/core/net/MailTo#parse(android.net.Uri)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html uri)` Parse and decode a mailto scheme Uri. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/net/MailTo#toString()()` |

## Constants

### MAILTO_SCHEME

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final String MAILTO_SCHEME = "mailto:"
```

## Public methods

### getBcc

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable String getBcc()
```

Retrieve the BCC address line from the parsed mailto URI. This could be several email address that are comma-space delimited. If no BCC line was specified, then null is return

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | comma delimited email addresses or null |

### getBody

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable String getBody()
```

Retrieve the body line from the parsed mailto URI. If no body line was specified, then null is return

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | body or null |

### getCc

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable String getCc()
```

Retrieve the CC address line from the parsed mailto URI. This could be several email address that are comma-space delimited. If no CC line was specified, then null is return

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | comma delimited email addresses or null |

### getHeaders

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable Map<String, String> getHeaders()
```

Retrieve all the parsed email headers from the mailto URI

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/String.html>` | map containing all parsed values |

### getSubject

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable String getSubject()
```

Retrieve the subject line from the parsed mailto URI. If no subject line was specified, then null is return

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | subject or null |

### getTo

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public @Nullable String getTo()
```

Retrieve the To address line from the parsed mailto URI. This could be several email address that are comma-space delimited. If no To line was specified, then null is return

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | comma delimited email addresses or null |

### isMailTo

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static boolean isMailTo(@Nullable String uri)
```

Test to see if the given string is a mailto URI

*Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your URI string with the scheme using lower case letters, and normalize any URIs you receive from outside of Android to ensure the scheme is lower case.*

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html uri` | string to be tested |

| Returns |
|---|---|
| `boolean` | true if the string is a mailto URI |

### isMailTo

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static boolean isMailTo(@Nullable Uri uri)
```

Test to see if the given Uri is a mailto URI

*Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your Uri with the scheme using lower case letters, and normalize any Uris you receive from outside of Android to ensure the scheme is lower case.*

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html uri` | Uri to be tested |

| Returns |
|---|---|
| `boolean` | true if the Uri is a mailto URI |

### parse

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull MailTo parse(@NonNull String uri)
```

Parse and decode a mailto scheme string. This parser implements RFC 6068. The returned object can be queried for the parsed parameters.

*Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your URI string with the scheme using lower case letters, and normalize any URIs you receive from outside of Android to ensure the scheme is lower case.*

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html uri` | String containing a mailto URI |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/net/MailTo` | MailTo object |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/core/net/ParseException` | if the scheme is not a mailto URI |

### parse

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull MailTo parse(@NonNull Uri uri)
```

Parse and decode a mailto scheme Uri. This parser implements RFC 6068. The returned object can be queried for the parsed parameters.

*Note: scheme name matching is case-sensitive, unlike the formal RFC. As a result, you should always ensure that you write your Uri with the scheme using lower case letters, and normalize any Uris you receive from outside of Android to ensure the scheme is lower case.*

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html uri` | Uri containing a mailto URI |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/net/MailTo` | MailTo object |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/core/net/ParseException` | if the scheme is not a mailto URI |

### toString

```
public @NonNull String toString()
```