2012-10-30 6 views
1

Android 애플리케이션에서 전자 메일을 보내야합니다. 따라서 전자 메일 클라이언트 응용 프로그램에 2 개의 매개 변수 (전자 메일 및 제목)를 보내지 만 응용 프로그램이 전자 메일 클라이언트를 열면 제목 매개 변수 만 추가되고 전자 메일 매개 변수는 설정되지 않습니다.Android에서 전자 메일 보내기

어떻게 해결할 수 있습니까?

String getMail = email.toString(); 
    Log.d("GET MAIL:",getMail); 
    String subject = "Subject"; 
    Intent emailIntent = new Intent(Intent.ACTION_SEND); 
    emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail); 
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 

// need this to prompts email client only             
emailIntent.setType("message/rfc822"); 
startActivity(Intent.createChooser(emailIntent,"Choose E-mail client:")); 

답변

2

변경 emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);

에 :

emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{getMail}); 
2

getMail이 있어야 할 문자열 배열 ...

3
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 

        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject"); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From App"); 

        startActivity(Intent.createChooser(emailIntent, "Send mail..."));