Android app call the local mailbox

/ **
* Regular expression: Verify E-mail
* /
public static String REGEX_EMAIL Final = "^ ([A-z0-9A-the Z-] + [- | \.]?) + [A-z0-9A-the Z-] @ (?. [the Z-A-z0-9A] + (- [the Z-A-z0-9A] +) \) + [A-zA-the Z] {2,} $ ";
@Event ( R.id. btn_send )
Private void the sendEmail (View View) {
String = edt_addressee.getText Addressee () toString ();.
String Content = edt_content.getText () toString ();.
String title = edt_title.getText () toString ();.
IF (TextUtils.isEmpty (addressee)) {
Toast.makeText (the this, "the recipient can not be empty", Toast.LENGTH_SHORT) the .Show ();
return;
}
IF {(isEmail (addressee)!)
Toast.makeText ( this, "Please enter a valid email address", Toast.LENGTH_SHORT) the .Show ();
return;
}
IF (TextUtils.isEmpty (Content)) {
Toast.makeText (this, "can not be empty", Toast.LENGTH_SHORT) the .Show ();
return;
}
IF (TextUtils.isEmpty (title)) {
Toast.makeText (this, "the title can not be empty", Toast. LENGTH_SHORT) the .Show ();
return;
}
// must explicitly use mailto prefix to the e-mail address, if the
Uri URI = Uri.parse ( "mailto:" + Addressee);
String [] = {In email Addressee};
the Intent Intent the Intent new new = (Intent.ACTION_SENDTO, uri);
intent.putExtra (Intent.EXTRA_EMAIL, Email); // results will not match any application
intent.putExtra (Intent.EXTRA_CC, email); // Cc
intent.putExtra (Intent.EXTRA_SUBJECT, title); // theme
intent.putExtra (Intent.EXTRA_TEXT, content); // text
startActivity (Intent.createChooser (intent, "Please select the mail class application"));
}

/ **
* check mailbox
*
* @param In Email
* @return through check returns true, otherwise to false
* /
public static Boolean isEmail (String In Email) {
return Pattern.matches (REGEX_EMAIL, In Email);
}

Reproduced in: https: //www.jianshu.com/p/ec99fc79fcfd

Guess you like

Origin blog.csdn.net/weixin_33943836/article/details/91140294