通过邮件发送图像
我写了一封邮件,将发送带有图像作为附件的电子邮件。这些图像显示在 yahoo 和 gmail 中。但 hotmail 在应该有图像的地方显示一个方形灰色框。以下是构建图像的代码。当然,我会使用 cid 在邮件中引用它。预先非常感谢。
l_embedImage = new MimeBodyPart();
l_dataSource = new FileDataSource(new File(l_imagesBaseDirectory + "/" + l_completeImagePath));
l_dataHandler = new DataHandler(l_dataSource);
l_embedImage.setDataHandler(l_dataHandler);
l_embedImage.setHeader("Content-ID", "<" + l_cid + ">");
l_embedImage.setHeader("Content-Type", "image/gif");
l_embedImage.setHeader("discrete-type","image");
l_embedImage.setHeader("content-transfer-encoding", "base64");
p_multipart.addBodyPart(l_embedImage);
I've written a mail that'll send emails with images as attachments. The images are displaying in yahoo and gmail. But hotmail is displaying a square grey box wherever there should be an image. The following is the code that builds the image. Of course I'm reffering to it in the mail using cid. Thanks a lot in advance.
l_embedImage = new MimeBodyPart();
l_dataSource = new FileDataSource(new File(l_imagesBaseDirectory + "/" + l_completeImagePath));
l_dataHandler = new DataHandler(l_dataSource);
l_embedImage.setDataHandler(l_dataHandler);
l_embedImage.setHeader("Content-ID", "<" + l_cid + ">");
l_embedImage.setHeader("Content-Type", "image/gif");
l_embedImage.setHeader("discrete-type","image");
l_embedImage.setHeader("content-transfer-encoding", "base64");
p_multipart.addBodyPart(l_embedImage);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我完成成为可信邮件服务器的步骤之前,我在发送电子邮件方面遇到了麻烦。
查看以下 URL 中的步骤 4(“验证您的出站电子邮件:发布发件人策略框架 (SPF) 记录”):
http://postmaster.msn.com/Guidelines.aspx
I was having troubles with delivering e-mails until I went through the steps to become a trusted mail server.
Check out step 4 ("Authenticate your outbound e-mail: Publish Sender Policy Framework (SPF) records") in the following URL:
http://postmaster.msn.com/Guidelines.aspx
我认为hotmail不会自动加载它们,用户应该首先同意此消息:
像往常一样,微软必须完成程序员的生活;)
I think that hotmail doesn't load them automatically, the user should agree on this message first:
As usual Microsoft must complete programmers life ;)