发送带有PDF附件的emai [关闭]

问题描述 投票:-1回答:1
我正在尝试发送我在应用程序中创建的带有PDF附件的电子邮件。要使用this,我需要添加什么内容?或者,也许有人知道一种发送带有PDF附件的电子邮件的更好方法吗?感谢您的回复。
java android pdf email-attachments
1个回答
0
投票
如果要共享设备中已经存在的PDF,则可以使用Intent通过电子邮件共享PDF。

share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intentShareFile = new Intent(Intent.ACTION_SEND); File fileWithinMyDir = new File(getFilepath("document.pdf")); if(fileWithinMyDir.exists()) { intentShareFile.setType("application/pdf"); intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+getFilepath("document.pdf"))); intentShareFile.putExtra(Intent.EXTRA_SUBJECT, "Subject of the Email"); intentShareFile.putExtra(Intent.EXTRA_TEXT, "Body of the Email"); startActivity(Intent.createChooser(intentShareFile, "Share File")); } } }); private String getFilepath(String filename) { return new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/Download/" + filename).getPath(); }

希望这就是您要的
© www.soinside.com 2019 - 2024. All rights reserved.