使用 GMailSender 从 Android 应用程序发送带有附件的电子邮件在 Transport.send 处失败
我正在尝试从我的 Android 应用程序发送一封带有图像作为附件的电子邮件。我关注了这篇文章(以及其他许多文章):通过 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 对象。
I am trying to send an email with an image as attachment from my android app. I have followed this post (among many others): Sending email with attachment through GMailSender?
So I've done the same thing, and I can send emails, but only without attachments. Unfortunately, Transport.send seems to fail. After a while it shows:
D/SntpClient( 61): request time failed: java.net.SocketException: Address family not supported by protocol
I tried creating the File object in different ways (streamUri
I believe is correct):
Uri streamUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
File f = new File(streamUri.toString()); //I get an error if I pass only streamUri as parameter
and also
File f = new File(streamUri.getEncodedPath());
But I get:
( 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)
So I suspect I might be creating the File object incorrectly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
路径不正确,这解决了问题:
The path was incorrect, this fixed the problem: