在android中发送带有附件的电子邮件

在android中发送带有附件的电子邮件,android,email,android-intent,email-attachments,Android,Email,Android Intent,Email Attachments,我试图发送一封带有附件的电子邮件,该附件保存在emulator上的SDCard上,但问题是它发送电子邮件时没有附件。请告诉我哪里出错了 这是密码 Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Int

我试图发送一封带有附件的电子邮件,该附件保存在emulator上的SDCard上,但问题是它发送电子邮件时没有附件。请告诉我哪里出错了

这是密码

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
                emailIntent.setType("text/plain");
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] 
                {"djkgotsod@gmail.com"}); 
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 
                "Dear Sir"); 
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
                "Im doing Android");                 
                Log.v(getClass().getSimpleName(), "sPhotoUri=" + Uri.parse("/mnt/sdcard/../.."+getFilesDir()+"/"+myfile));

                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("/mnt/sdcard/../.."+getFilesDir()+"/"+myfile));
                startActivity(Intent.createChooser(emailIntent, "Send mail..."));

这是我的原木猫

01-20 17:59:04.927: E/Trace(31078): error opening trace file: No such file or directory (2)
01-20 17:59:06.117: D/gralloc_goldfish(31078): Emulator without GPU emulation detected.
01-20 17:59:08.917: V/Main(31078): sPhotoUri=/mnt/sdcard/../../data/data/com.example.emailandroid/files//mnt/sdcard/myfile.csv
01-20 17:59:10.077: I/Choreographer(31078): Skipped 112 frames!  The application may be doing too much work on its main thread.
01-20 17:59:15.267: I/Choreographer(31078): Skipped 30 frames!  The application may be doing too much work on its main thread.


非常感谢您的帮助

因为您的附件路径不正确。你的日志清楚地指出了你做错了什么:

/mnt/sdcard/../../data/data/com.example.emailandroid/files//mnt/sdcard/myfile.csv

决不使用硬编码路径,决不当您在根目录下2级时,决不以所示代码中的方式遍历目录。用于获取外部存储(根本不需要SD卡)根目录并附加您的相对路径以获得正确有效的位置。

现在我的文件名(myfile)出现错误。它用红线划出,所以我无法调试我的应用程序。请帮帮我