无法在Android中附加电子邮件附件 [英] Unable to attach an attachment with email in android
问题描述
我正在尝试发送带有附件的电子邮件,我已经创建了一个pdf文件以及一个文本文件,用于附加一个文本文件并发送一封电子邮件,我正在使用此代码
I am trying to send an email with an attachment, I have created a pdf file as well as a text file, for attaching a text file and sending an email i am using this code
email.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String path = "/ScriptEmails/"+ filename;
String filepath = Environment.getExternalStorageDirectory()+File.separator+"Screenwriter"+File.separator+path;
sendEmail ("text", "enter email here", "Script from scriptwrite android", "Your script is attached", filepath);
发送电子邮件功能如下:
And the send email function is like this:
public void sendEmail (String attachmentType, String emails, String subject, String text, String filePath)
{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(attachmentType);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emails});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+filePath/*mnt/sdcard/Myimage.jpeg"*/));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
现在,路径是正确的,文件名是正确的,但在发送电子邮件时,它说,附件无法发送。
now, the path is correct, the file name is correct, yet upon sending an email, it says, the attachment couldn't be send.
我认为我不会放对于我的文件类型,右键ATTACHMENT TYPE。
What i think is that i am not putting right ATTACHMENT TYPE for my file type.
什么是文本文件的附件类型以及pdf文件的附件类型?
What would be the attachment type for a text file and what would be an attachment type for a pdf file?
我正在使用的文本文件(txt / plain)是否正确?
for text file i am using (txt/plain) is this correct?
推荐答案
检查:
希望这有帮助。
这篇关于无法在Android中附加电子邮件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!