gpt4 book ai didi

安卓。发送多附件电子邮件

转载 作者:行者123 更新时间:2023-11-30 04:52:29 30 4
gpt4 key购买 nike

我想通过

发送电子邮件
startActivity(Intent.createChooser(new Intent(android.content.Intent.ACTION_SEND)))

我知道要将文件附加到电子邮件我需要

intentEmail.putExtra(android.content.Intent.EXTRA_STREAM, <Uri of file>)

但我需要附加几个文件。我该怎么做?

最佳答案

这应该可以发送多个附件

public static void sendEmail(Context context, String emailTo, String emailCC,
String subject, String message, List<String> filePaths)
{
//send email with multiple attachments
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{emailTo});
emailIntent.putExtra(android.content.Intent.EXTRA_CC,
new String[]{emailCC});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
message);
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Uri's
for (String file : filePaths)
{
File fileIn = new File(file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}

emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
context.startActivity(emailIntent);
}

关于安卓。发送多附件电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2847545/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com