Google is committed to advancing racial equity for Black communities. See how.

MailTo

public final class MailTo
extends Object

java.lang.Object
   ↳ androidx.core.net.MailTo


MailTo URI parser. Replacement for MailTo.

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

String MAILTO_SCHEME

Public methods

String getBcc()

Retrieve the BCC address line from the parsed mailto URI.

String getBody()

Retrieve the body line from the parsed mailto URI.

String getCc()

Retrieve the CC address line from the parsed mailto URI.

Map<String, String> getHeaders()

Retrieve all the parsed email headers from the mailto URI

String getSubject()

Retrieve the subject line from the parsed mailto URI.

String getTo()

Retrieve the To address line from the parsed mailto URI.

static boolean isMailTo(String uri)

Test to see if the given string is a mailto URI

Note: scheme name matching is case-sensitive, unlike the formal RFC.

static boolean isMailTo(Uri uri)

Test to see if the given Uri is a mailto URI

Note: scheme name matching is case-sensitive, unlike the formal RFC.

static MailTo parse(String uri)

Parse and decode a mailto scheme string.

static MailTo parse(Uri uri)

Parse and decode a mailto scheme Uri.

String toString()

Inherited methods

Constants

MAILTO_SCHEME

public static final String MAILTO_SCHEME

Constant Value: "mailto:"

Public methods

getBcc

public 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
String comma delimited email addresses or null

getBody

public String getBody ()

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

Returns
String body or null

getCc

public 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
String comma delimited email addresses or null

getHeaders

public Map<String, String> getHeaders ()

Retrieve all the parsed email headers from the mailto URI

Returns
Map<String, String> map containing all parsed values

getSubject

public String getSubject ()

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

Returns
String subject or null

getTo

public 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
String comma delimited email addresses or null

isMailTo

public static boolean isMailTo (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
uri String: string to be tested

Returns
boolean true if the string is a mailto URI

isMailTo

public static boolean isMailTo (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
uri Uri: Uri to be tested

Returns
boolean true if the Uri is a mailto URI

parse

public static MailTo parse (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
uri String: String containing a mailto URI

Returns
MailTo MailTo object

Throws
ParseException if the scheme is not a mailto URI

parse

public static MailTo parse (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
uri Uri: Uri containing a mailto URI

Returns
MailTo MailTo object

Throws
ParseException if the scheme is not a mailto URI

toString

public String toString ()

Returns
String