# MailTo

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/net/MailTo "View this page in Java")

<br />

```
class MailTo
```

<br />

*** ** * ** ***

MailTo URI parser. Replacement for[android.net.MailTo](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                                         |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| `const `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | [MAILTO_SCHEME](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#MAILTO_SCHEME())` = "mailto:"` |

|                                                                                                                                                                              ### Public functions                                                                                                                                                                               |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                                                                                                                                            | [getBcc](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#getBcc())`()` Retrieve the BCC address line from the parsed mailto URI.                                                                                                    |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                                                                                                                                            | [getBody](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#getBody())`()` Retrieve the body line from the parsed mailto URI.                                                                                                         |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                                                                                                                                            | [getCc](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#getCc())`()` Retrieve the CC address line from the parsed mailto URI.                                                                                                       |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)`)`[Map](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>?` | [getHeaders](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#getHeaders())`()` Retrieve all the parsed email headers from the mailto URI                                                                                            |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                                                                                                                                            | [getSubject](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#getSubject())`()` Retrieve the subject line from the parsed mailto URI.                                                                                                |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                                                                                                                                            | [getTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#getTo())`()` Retrieve the To address line from the parsed mailto URI.                                                                                                       |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                                               | [isMailTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#isMailTo(java.lang.String))`(uri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?)` Test to see if the given string is a mailto URI |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                                               | [isMailTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#isMailTo(android.net.Uri))`(uri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`?)` Test to see if the given Uri is a mailto URI                   |
| `java-static `[MailTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo)                                                                                                                                                                                                                                                                                 | [parse](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#parse(java.lang.String))`(uri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Parse and decode a mailto scheme string.               |
| `java-static `[MailTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo)                                                                                                                                                                                                                                                                                 | [parse](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#parse(android.net.Uri))`(uri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`)` Parse and decode a mailto scheme Uri.                                 |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                                                                                                                                                                                                               | [toString](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo#toString())`()`                                                                                                                                                          |

## Constants

### MAILTO_SCHEME

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

```
const val MAILTO_SCHEME = "mailto:": String!
```  

## Public functions

### getBcc

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

```
fun getBcc(): String?
```

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                                        |
|--------------------------------------------------------------------------------------|-----------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | comma delimited email addresses or null |

### getBody

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

```
fun getBody(): String?
```

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

|                                       Returns                                        |
|--------------------------------------------------------------------------------------|--------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | body or null |

### getCc

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

```
fun getCc(): String?
```

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                                        |
|--------------------------------------------------------------------------------------|-----------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | comma delimited email addresses or null |

### getHeaders

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

```
fun getHeaders(): (Mutable)Map<String!, String!>?
```

Retrieve all the parsed email headers from the mailto URI  

|                                                                                                                                                                                     Returns                                                                                                                                                                                     |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)`)`[Map](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>?` | map containing all parsed values |

### getSubject

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

```
fun getSubject(): String?
```

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

|                                       Returns                                        |
|--------------------------------------------------------------------------------------|-----------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | subject or null |

### getTo

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

```
fun getTo(): String?
```

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                                        |
|--------------------------------------------------------------------------------------|-----------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | comma delimited email addresses or null |

### isMailTo

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

```
java-static fun isMailTo(uri: String?): Boolean
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------|
| `uri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | string to be tested |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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)  

```
java-static fun isMailTo(uri: Uri?): Boolean
```

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                                   |
|-------------------------------------------------------------------------------|------------------|
| `uri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`?` | Uri to be tested |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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)  

```
java-static fun parse(uri: String): MailTo
```

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                                        |
|------------------------------------------------------------------------------------------|--------------------------------|
| `uri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | String containing a mailto URI |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|---------------|
| [MailTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo) | MailTo object |

|                                                       Throws                                                        |
|---------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [androidx.core.net.ParseException](https://developer.android.com/reference/kotlin/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)  

```
java-static fun parse(uri: Uri): MailTo
```

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                                 |
|----------------------------------------------------------------------------|-----------------------------|
| `uri: `[Uri](https://developer.android.com/reference/android/net/Uri.html) | Uri containing a mailto URI |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|---------------|
| [MailTo](https://developer.android.com/reference/kotlin/androidx/core/net/MailTo) | MailTo object |

|                                                       Throws                                                        |
|---------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [androidx.core.net.ParseException](https://developer.android.com/reference/kotlin/androidx/core/net/ParseException) | if the scheme is not a mailto URI |

### toString

```
fun toString(): String
```