繁体   English   中英

如何通过电子邮件共享文件对象?

[英]how to share a File object by email?

我以编程方式创建File对象。 我想知道如何直接通过电子邮件共享它而不将其保存在设备上。

我想要一个这样的方法:

private void sendFileByEmail(File aFile, String emailTitle) 
{

 Intent intentShareFile = new Intent(Intent.ACTION_SEND);
intentShareFile.putExtra(Intent.EXTRA_SUBJECT, emailTitle);

// and then ???...

}

谢谢你的帮助 !

这可能是选项

private void sendFileByEmail(File aFile, String emailTitle) 
{


Uri path = Uri.fromFile(afile); 
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// set the type to 'email'
emailIntent .setType("vnd.android.cursor.dir/email");
String to[] = {"asd@gmail.com"};
emailIntent .putExtra(Intent.EXTRA_EMAIL, to);
// the attachment
emailIntent .putExtra(Intent.EXTRA_STREAM, path);
// the mail subject
emailIntent .putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(emailIntent , "Send email..."));

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM