ANDROID | send email attachment only with email clients -
please read question before marking duplicate. :)
i want send email attachment. have used action_sendto
code:
intent intent = new intent(intent.action_sendto); intent.setdata(uri.parse("mailto:")); intent.putextra(intent.extra_email, new string[]{ wrapper.instance.getsupportemail()}); intent.putextra(intent.extra_subject, getresources().getstring(resourcetitleid)); intent.putextra(intent.extra_stream, uri.parse("file://" + filepath)); try { ctx.startactivity(intent.createchooser(intent, "send mail...")); } catch (android.content.activitynotfoundexception ex) { toast.maketext(ctx, "there no email clients installed.", toast.length_short).show(); }
it shows email clients, see picture below:
but attachment not working except gmail.
i have tried achieve action_send
code:
intent intent = new intent(intent.action_send); intent.putextra(intent.extra_email, new string[]{ wrapper.instance.getsupportemail()}); intent.putextra(intent.extra_subject, getresources().getstring(resourcetitleid)); intent.settype("message/rfc822"); intent.putextra(intent.extra_stream, uri.parse("file://" + filepath));
it shows supported apps, please see picture below:
but attachement working file on email clients.
i have read on many stack-overflow answers that
intent.settype("message/rfc822");
this solve problem. not.
i want email clients shown supports attachment.
string recepientemail = ""; // either set destination email or leave empty intent intent = new intent(intent.action_sendto); intent.setdata(uri.parse("mailto:" + recepientemail)); startactivity(intent);
the point use action_sendto action , mailto: data. if want let user specify destination email, use mailto:; if specify email yourself, use mailto:name@domain.com
suggested method filters application, can send email(such default email app or gmail)
Comments
Post a Comment