如何在Android应用程序发送邮件附加文件? [英] How to Attach files with sending mail in android application?

查看:102
本文介绍了如何在Android应用程序发送邮件附加文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过我的应用程序发送邮件。 对于我使用下面的code。

I am sending mail through my application. For that I am using following code.

    Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

这只是做工精细,但我要附加一个XML文件,用它。 可能吗?怎么样?

It just work fine but i want to attach an xml file with it. Is it possible? How?

推荐答案

有很多类似的问题问在堆栈溢出完美的解决方案了。

There are lots of similar questions asked with perfect solution in Stack Overflow already.

您可以看向几个:<一href="http://stackoverflow.com/questions/587917/trying-to-attach-a-file-from-sd-card-to-email">here和<一href="http://stackoverflow.com/questions/1834567/android-possible-to-attach-a-file-to-email-without-writing-to-sd">here和<一href="http://stackoverflow.com/questions/2264622/android-multiple-email-attachments-using-intent">here

解决方案是与电子邮件的使用意图:多了一个 putExtra用Key-Extra_Stream和价值URI到文件

Solution is to use with email intent : one more putExtra with Key-Extra_Stream and Value-uri to file.

和请到通过常见问题解答以undersatand如何从网站更好地benifit。

And please go through the FAQ to undersatand How to better benifit from the site.

这篇关于如何在Android应用程序发送邮件附加文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆