Example usage for android.content Intent EXTRA_EMAIL

List of usage examples for android.content Intent EXTRA_EMAIL

Introduction

In this page you can find the example usage for android.content Intent EXTRA_EMAIL.

Prototype

String EXTRA_EMAIL

To view the source code for android.content Intent EXTRA_EMAIL.

Click Source Link

Document

A String[] holding e-mail addresses that should be delivered to.

Usage

From source file:Main.java

public static void sendEmail(Context context, String chooserTitle, String mailAddress, String subject,
        String preContent) {/* w  w  w .j a  v  a 2s .c om*/
    final Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { mailAddress });
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    String content = "\n\n=====================\n";
    content += "Device Environment: \n----\n" + preContent;
    emailIntent.putExtra(Intent.EXTRA_TEXT, content);
    context.startActivity(Intent.createChooser(emailIntent, chooserTitle));
}

From source file:Main.java

public static void sendEmail(Context ctx, String[] emailAddresses, String[] CCAddresses, String subject,
        String message) {/*from  w ww  .  j  a v  a2  s  .  co  m*/

    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    // emailIntent.setType("text/plain");
    emailIntent.setData(Uri.parse("mailto:"));
    String[] to = emailAddresses;
    String[] cc = CCAddresses;
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    if (CCAddresses != null) {
        emailIntent.putExtra(Intent.EXTRA_CC, cc);
    }
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");

    ctx.startActivity(Intent.createChooser(emailIntent, "Email"));

}

From source file:Main.java

/** Launch an email intent if the device is capable.
 *
 * @param activity The parent activity (for context)
 * @param addr The address to email (not the full URI)
 * @param text The email body//w w  w.ja  v  a 2s. c o  m
 */
public static void launchEmailIntent(final Activity activity, String addr, String text) {
    Log.i(LOG_TAG, "Launch email intent from " + activity.getLocalClassName());
    // create email intent
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { addr });
    emailIntent.setType("text/plain");
    // make sure there is an activity which can handle the intent.
    PackageManager emailpackageManager = activity.getPackageManager();
    List<ResolveInfo> emailresolveInfos = emailpackageManager.queryIntentActivities(emailIntent, 0);
    if (emailresolveInfos.size() > 0) {
        activity.startActivity(emailIntent);
    }
}

From source file:com.manning.androidhacks.hack004.util.LaunchEmailUtil.java

public static void launchEmailToIntent(Context context) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "feed@back.com" });
    intent.putExtra(Intent.EXTRA_SUBJECT, "[50AH] Feedback");
    intent.putExtra(Intent.EXTRA_TEXT, "Feedback:\n");
    context.startActivity(Intent.createChooser(intent, "Send feedback"));
}

From source file:com.renard.ocr.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    }/*from   w w  w.j  av a 2 s.c o  m*/
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }
    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

From source file:com.example.linhdq.test.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }/*from w w  w .j  av a2s  . com*/
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

From source file:com.manning.androidhacks.hack036.util.LaunchEmailUtil.java

public static void launchEmailToIntent(Context context) {
    Intent msg = new Intent(Intent.ACTION_SEND);

    StringBuilder body = new StringBuilder("\n\n----------\n");
    body.append(EnvironmentInfoUtil.getApplicationInfo(context));

    msg.putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.mail_support_feedback_to).split(", "));
    msg.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.mail_support_feedback_subject));
    msg.putExtra(Intent.EXTRA_TEXT, body.toString());

    msg.setType("message/rfc822");
    context.startActivity(Intent.createChooser(msg, context.getString(R.string.pref_sendemail_title)));
}

From source file:am.project.x.utils.ContextUtils.java

/**
 * ???//from  w  w w.j  ava  2  s. c  om
 *
 * @param context    Context
 * @param subject    
 * @param attachment 
 * @param addresses  ?
 */
public static void sendEmail(Context context, @Nullable String subject, @Nullable Uri attachment,
        String... addresses) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    if (subject != null)
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (attachment != null)
        intent.putExtra(Intent.EXTRA_STREAM, attachment);
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    }
}

From source file:com.vigek.iotcore.common.Notify.java

public static void CrashReport(final Context cont, final String crashReport) {
    AlertDialog.Builder builder = new AlertDialog.Builder(cont);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle("ERROR");
    builder.setMessage(crashReport);/* w ww .j  a  va2s .  co m*/
    builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            // ???
            Intent i = new Intent(Intent.ACTION_SEND);
            // i.setType("text/plain"); //?
            i.setType("message/rfc822"); // 
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { "dustin.guo.sz@qq.com" });
            i.putExtra(Intent.EXTRA_SUBJECT, "Vigek ? - ");
            i.putExtra(Intent.EXTRA_TEXT, crashReport);
            cont.startActivity(Intent.createChooser(i, "???"));
            // ??
            AppManager.getAppManager().AppExit(cont);
        }
    });
    builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            // ??
            AppManager.getAppManager().AppExit(cont);
        }
    });
    builder.show();
}

From source file:com.example.linhdq.test.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(Context context, String subject, File file, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }/*from   w  w w  . ja v a2  s  .c  om*/
    if (file.exists()) {
        final Uri uriForFile = FileProvider.getUriForFile(context,
                context.getString(R.string.config_share_file_auth), file);
        intent.putExtra(Intent.EXTRA_STREAM, uriForFile);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}