如何在电子邮件中附加pdf文件 [英] How to attach pdf file in an email

查看:385
本文介绍了如何在电子邮件中附加pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在电子邮件中附加pdf文件,我尝试使用此代码发送包含pdf文件的电子邮件.

I want to attach a pdf file in an e-mail, I tried this code to send an email containing pdf file.

String to = textTo.getText().toString();
String subject = textSubject.getText().toString();
String message = textMessage.getText().toString();

Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});

email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);             

email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));

推荐答案

尝试一下:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("application/pdf");
shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "abc@gmail.com" });
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "test " +    test);
shareIntent.putExtra(Intent.EXTRA_TEXT, "test"); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///MyAPP/"+"test.pdf"));
startActivity(shareIntent);

希望这会有所帮助.

这篇关于如何在电子邮件中附加pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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