【发布时间】:2011-12-17 23:15:32
【问题描述】:
我正在尝试从我的 Android 应用程序发送一封带有图像作为附件的电子邮件。我关注了这篇文章(以及许多其他帖子):Sending email with attachment through GMailSender?
所以我做了同样的事情,我可以发送电子邮件,但只能不带附件。不幸的是, Transport.send 似乎失败了。过了一会儿,它显示:
D/SntpClient( 61): request time failed: java.net.SocketException: Address family not supported by protocol
我尝试以不同的方式创建 File 对象(streamUri 我相信是正确的):
Uri streamUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
File f = new File(streamUri.toString()); //I get an error if I pass only streamUri as parameter
还有
File f = new File(streamUri.getEncodedPath());
但我明白了:
( 418): IOException while sending message
( 418): javax.mail.MessagingException: IOException while sending message;
( 418): nested exception is:
( 418): java.io.FileNotFoundException: /media/external/images/media/2 (No such file or directory)
所以我怀疑我可能错误地创建了 File 对象。
【问题讨论】:
标签: java android gmail email-attachments jakarta-mail