-
Notifications
You must be signed in to change notification settings - Fork 24
EMailHelper
Basically its a set of handy methods to prepare an E-Mail using standard Android Intent.
public static boolean isValidEmail(String emailAddressToCheck)
, returns true if given String might be a valid E-Mail address. Based on standard pattern.
Sending E-Mails methods with variety sets of parameters. All of these methods returns true in case if no Exception happens while starting EMail Intent. Also this class has a list of known Android email apps packages to be applied to avoid email app picker and thus intent starts faster because user doesn't have to pick the email app.
public static boolean sendEmail(Context context,
final String receiver,
final String subject,
final String text)
Starts EMail intent with filled by given receiver (single email address), subject and text (message)
public static boolean sendEmail(Context context,
final String[] receivers,
final String subject,
final String text)
Starts EMail intent with filled by given receivers (array of email address), subject and text
public static boolean sendEmail(final Context context,
final String receiver,
final String subject,
final String text,
final String pickerTitle,
final String securityExceptionMessage,
final String noAssociatedAppErrorMessage)
Starts EMail intent with filled by given receiver (single email address), subject and text. pickerTitle
is a title of E-Mail app picker/chooser. securityExceptionMessage
- custom message shown in case of security exception, noAssociatedAppErrorMessage
- custom message shown in case of no E-Mail app could be found.
public static boolean sendEmail(final Context context,
final String[] receivers,
final String subject,
final String text,
String pickerTitle,
String securityExceptionMessage,
String noAssociatedAppErrorMessage)
Starts EMail intent with filled by given receivers (array of email address), subject and text. pickerTitle
is a title of E-Mail app picker/chooser. securityErrorMessage
- custom message shown in case of security exception, noAssociatedAppErrorMessage
- custom message shown in case of no E-Mail app could be found.
mail with attachments
public static boolean sendEmail(Context context,
final String receiver,
final String subject,
final String text,
final File... files)
Starts EMail intent with filled by given receiver (single email address), subject, text and Files as attachments. If no files provided regular (without attachments) email will be sent.
public static void sendEmail(Context context,
final String[] receivers,
final String subject,
final String text,
final File... files)
Starts E-Mail intent with filled by given receivers (array of email address), subject, text and array of files as attachments. If no files provided regular (without attachments) email will be sent.
public static boolean sendEmail(Context context,
final String receiver,
final String subject,
final String text,
final String pickerTitle,
final String securityExceptionMessage,
final String noAssociatedAppErrorMessage,
final File... files)
Starts EMail intent with filled by given receiver (single email address), subject, text and Files as attachments. pickerTitle
is a title of E-Mail app picker/chooser. securityExceptionMessage
- custom message shown in case of security exception, noAssociatedAppErrorMessage
- custom message shown in case of no E-Mail app could be found. If no files provided regular (without attachments) email will be sent.
public static boolean sendEmail(Context context,
final String[] receivers,
final String subject,
final String text,
String pickerTitle,
String securityExceptionMessage,
String noAssociatedAppErrorMessage,
final File... files)
Starts E-Mail intent with filled by given receivers (array of email address), subject, text and array of files as attachments. pickerTitle
is a title of E-Mail app picker/chooser. securityErrorMessage
- custom message shown in case of security exception, noAssociatedAppErrorMessage
- custom message shown in case of no E-Mail app could be found.
Default messages for Picker Title, SecurityException and No App are: "Send EMail using:" // Email app Picker Title "Sending EMail has been forbidden by permissions" // SecurityException "No EMail app has been found" // no Email app installed