send Mail Attached Single File using Intent - Android Intent

Android examples for Intent:Send Email

Description

send Mail Attached Single File using Intent

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class Main {
    public static void sendMailAttachedSingleFile(Context context,
            String email, String subject, Uri uri) {
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("application/pdf");
        sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
        sendIntent.putExtra(Intent.EXTRA_TEXT, "");
        context.startActivity(sendIntent);
    }/*from  ww w  .j av  a2  s.  c o m*/
}

Related Tutorials