में फ़ाइल अटैचमेंट के साथ एक ईमेल कैसे भेजें, मैं अपने मेल के साथ .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- और – NagarjunaReddy
भेजें आपको "हार्ड-कोडेड" पथ का उपयोग नहीं करना चाहिए क्योंकि वे डिवाइस के आधार पर बदल सकते हैं। मेरा सुझाव है कि आप फ़ाइल स्थान की परिभाषा को बदल रहे हैं: फ़ाइल फ़ाइल स्थान = नई फ़ाइल (Environment.getExternalStorageDirectory()। GetAbsolutePath(), फ़ाइल नाम); फिर परिभाषित करें: उरी पथ = Uri.from फ़ाइल (फ़ाइल स्थान); और इसे अपने इरादे में रखें: ईमेलइन्टेंट .putExtra (Intent.EXTRA_STREAM, पथ); –
emailIntent.putExtra (Intent.EXTRA_STREAM, फ़ाइल स्थान) मेरे लिए फ़ाइल संलग्न नहीं करेगा, लेकिन ईमेल INTent.putExtra (Intent.EXTRA_STREAM, Uri.parse ("file: //" + filelocation) का उपयोग करके) फिलिप ने ठीक काम किया था। – andytrombone