本文介绍了启动Gmail发送再加一个带有附件的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序,用户有机会导出和导入自己的数据文件,我想也增加通过邮件发送此数据文件作为附件的选项。我怎样才能做到这一点?感谢您的帮助。
In my application, the user have the opportunity to export and import his data file, and i want to add also the option to send this data file by mail as attachment.How can i do this?Thank you for your help.
推荐答案
我的code到了图片附件发送电子邮件:
My code to send email with a image attachment:
public void sendViaEmail(String pAttachmentPath, String pSubjectLine) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, pSubjectLine);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Screenshot ****************");
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile("file://" + pAttachmentPath));
mActivity.startActivity(emailIntent);
}
或
public void sendViaEmail(File pAttachmentFile, String pSubjectLine) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, pSubjectLine);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Screenshot ****************");
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pAttachmentFile));
mActivity.startActivity(emailIntent);
}
这篇关于启动Gmail发送再加一个带有附件的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!