내 메일에 .vcf 파일을 첨부하고 메일을 보내려합니다. 그러나 메일 첨부 파일없이 주소에서 수신됩니다. 나는 아래의 코드를 사용하지만이 코드와 내가 어디 잘못된지 모르겠다.안드로이드에 첨부 파일이있는 이메일을 보내는 방법
try {
String filelocation="/mnt/sdcard/contacts_sid.vcf";
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+filelocation));
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.setData(Uri.parse("mailto:"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
activity.finish();
} catch(Exception e) {
System.out.println("is exception raises during sending mail"+e);
}
한번보고 ... HTTP : //stackoverflow.com/questions/12798001/android-how-to-send-multiple-contacts-are-attached-in-single-vcf-file- and-send – NagarjunaReddy
"하드 코딩 된"경로는 장치에 따라 변경 될 수 있으므로 사용하면 안됩니다. 파일 위치의 정의를 다음과 같이 변경하는 것이 좋습니다. Filelocation = new File (Environment.getExternalStorageDirectory(). getAbsolutePath(), filename); 다음을 정의하십시오. Uri 경로 = Uri.fromFile (파일 위치); 귀하의 의도에 넣으십시오 : emailIntent .putExtra (Intent.EXTRA_STREAM, path); –
emailIntent.putExtra (Intent.EXTRA_STREAM, filelocation)는 파일을 첨부하지 않지만 emailIntent.putExtra (Intent.EXTRA_STREAM, Uri.parse ("file : //"+ filelocation))를 사용하면 Phillip이 정상적으로 작동합니다. – andytrombone