无法连接附件与Android的电子邮件 [英] Unable to attach an attachment with email in android

查看:120
本文介绍了无法连接附件与Android的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送带有附件的电子邮件,我创建的PDF文件以及文本文件,用于将文本文件和发送电子邮件我用这code

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.

我怎么想的是,我没有把正确的附件类型为我的文件类型。

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 /平)这是正确的?

for text file i am using (txt/plain) is this correct?

推荐答案

检查:

<一个href=\"http://stackoverflow.com/questions/9974987/how-to-send-mail-with-file-attachment-in-android\">Email与附件和例如

希望这有助于。

这篇关于无法连接附件与Android的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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