电子邮件与附件 [英] Email with attachment
本文介绍了电子邮件与附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用意图附件发送电子邮件。 该文件是存储在原始文件夹中的PDF文件。它小于200K。 但它显示的文件过大,无法连接。 Y' 帮我请..
意图=新的意图(Intent.ACTION_SEND);
in.setType(应用程序/ PDF格式);
in.putExtra(Intent.EXTRA_EMAIL,新的String [] {。email.getText()的toString()});
in.putExtra(Intent.EXTRA_SUBJECT,Android开发课程);
开放的我们的uri = Uri.parse(android.resource://deepak.android.samples/raw/android);
in.putExtra(Intent.EXTRA_STREAM,URI);
startActivity(Intent.createChooser(在发送电子邮件..));
解决方案
使用这个方法
意图emailIntent =新的意图(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
新的String [] {EMAILADDRESS});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,主题);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,身体);
字符串rawFolderPath =android.resource://+ getPackageName()
+/+ R.raw.shortcuts;
//这里我的文件名是我已经保存在/ RES shortcuts.pdf /原始文件夹
乌里emailUri = Uri.parse(rawFolderPath);
emailIntent.putExtra(Intent.EXTRA_STREAM,emailUri);
emailIntent.setType(应用程序/ PDF格式);
startActivity(Intent.createChooser(emailIntent,发送邮件...));
i am trying to send an email with an attachment using intent. the file is a pdf stored in the raw folder. it is less than 200k. but it shows file too large to attach. Y? help me pls..
Intent in = new Intent(Intent.ACTION_SEND);
in.setType("application/pdf");
in.putExtra(Intent.EXTRA_EMAIL,new String[]{email.getText().toString()});
in.putExtra(Intent.EXTRA_SUBJECT, "Android Development Course");
Uri uri = Uri.parse("android.resource://deepak.android.samples/raw/android");
in.putExtra(Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(in, "Sending email.."));
解决方案
use this method
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{"emailaddress"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Body");
String rawFolderPath = "android.resource://" + getPackageName()
+ "/" + R.raw.shortcuts;
// Here my file name is shortcuts.pdf which i have stored in /res/raw folder
Uri emailUri = Uri.parse(rawFolderPath );
emailIntent.putExtra(Intent.EXTRA_STREAM, emailUri);
emailIntent.setType("application/pdf");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
这篇关于电子邮件与附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文