We'll always try to open source what makes sense. I'm not sure it'd make sense to open source all GAE libraries since many of the calls talk to services. The javax.mail.* could fall under the "makes sense" category.
On Thu, Nov 19, 2009 at 12:07 PM, mably <fm2...@mably.com> wrote: > By the way, do you know if Google plans to open source some parts of > GAE librairies so we could investigate deeper when we encounter such a > problem ? > > On 19 nov, 21:01, mably <fm2...@mably.com> wrote: > > Any chance to see this bug fixed in the future ? > > > > Is there any documentation on the meaning of "Converting > > attachment data failed" error message ? > > > > On 19 nov, 20:55, "Ikai L (Google)" <ika...@google.com> wrote: > > > > > > > > > Looks like you're right. As far as I know there are no hidden methods. > > > > > Another workaround for this limitation could be to store incoming > images in > > > the data store on an incoming email, then reference them in the emails > that > > > get sent out. It's not ideal, but it may be the solution to what you > are > > > looking for. > > > > > On Wed, Nov 18, 2009 at 3:36 PM, mably <fm2...@mably.com> wrote: > > > > I haven't found a way to set a Content-ID header on a mimebodypart/ > > > > attachment using the low-level API. The MailService.Attachment class > > > > is quite rudimentary (only filename and data). > > > > > > May be some part of the low level API are still undocumented ? > > > > > > Thanx for all. > > > > > > On Nov 19, 12:25 am, "Ikai L (Google)" <ika...@google.com> wrote: > > > > > That's good information to know. We are not using Sun's JavaMail > > > > > implementation, so it's possible there are points of > incompatibility. > > > > > There's one last thing you may want to try: > > > > > > > > http://code.google.com/appengine/docs/java/javadoc/com/google/appengi... > > > > > > > The above page documents the Low-Level API. Try creating an email > object > > > > via > > > > > that API, setting the Content-ID of the attachment and the HTML tag > to > > > > point > > > > > to the cid. You're already doing that in the example you sent using > > > > > javax.mail, but I'm wondering if the low-level API is capable of > doing > > > > this. > > > > > If not, I'll open an issue. > > > > > > > On Wed, Nov 18, 2009 at 3:06 PM, mably <fm2...@mably.com> wrote: > > > > > > Of course, the code above doesn't need to be run in mail handler > > > > > > servlet :-) > > > > > > > > On Nov 19, 12:01 am, mably <fm2...@mably.com> wrote: > > > > > > > I've written a simple class sending an HTML email with an > embedded > > > > > > > image (cf. below) via GMail SMTP. It works perfectly fine when > run > > > > > > > locally from Eclipse. > > > > > > > > > The same code in a GAE mail servlet handler produce the > infamous > > > > > > > "Converting attachment data failed" error. > > > > > > > > > So it really seems to be a problem in GAE javamail > implementation. > > > > > > > > > /* > > > > > > > * Copyright (C) 2009 Francois Masurel > > > > > > > * > > > > > > > * This program is free software: you can redistribute it > and/or > > > > > > > modify > > > > > > > * it under the terms of the GNU General Public License as > published > > > > > > > by > > > > > > > * the Free Software Foundation, either version 3 of the > License, or > > > > > > > * any later version. > > > > > > > * > > > > > > > * This program is distributed in the hope that it will be > useful, > > > > > > > * but WITHOUT ANY WARRANTY; without even the implied warranty > of > > > > > > > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > the > > > > > > > * GNU General Public License for more details. > > > > > > > * > > > > > > > * You should have received a copy of the GNU General Public > License > > > > > > > * along with this program. If not, see < > > > >http://www.gnu.org/licenses/>. > > > > > > > > > */ > > > > > > > > > import java.io.ByteArrayOutputStream; > > > > > > > import java.io.IOException; > > > > > > > import java.io.InputStream; > > > > > > > import java.util.Properties; > > > > > > > > > import javax.mail.Message; > > > > > > > import javax.mail.Multipart; > > > > > > > import javax.mail.Session; > > > > > > > import javax.mail.Transport; > > > > > > > import javax.mail.internet.InternetAddress; > > > > > > > import javax.mail.internet.MimeBodyPart; > > > > > > > import javax.mail.internet.MimeMessage; > > > > > > > import javax.mail.internet.MimeMultipart; > > > > > > > > > /** > > > > > > > * @author Francois > > > > > > > * > > > > > > > */ > > > > > > > public class GMailSMTP { > > > > > > > > > private static final String SMTP_HOST_NAME = " > smtp.gmail.com"; > > > > > > > private static final int SMTP_HOST_PORT = 465; > > > > > > > private static final String SMTP_AUTH_USER = " > x...@gmail.com"; > > > > > > > private static final String SMTP_AUTH_PWD = "yyy"; > > > > > > > > > public static void main(String[] args) throws Exception{ > > > > > > > new GMailSMTP().test(); > > > > > > > } > > > > > > > > > public void test() throws Exception{ > > > > > > > Properties props = new Properties(); > > > > > > > > > props.put("mail.transport.protocol", "smtps"); > > > > > > > props.put("mail.smtps.host", SMTP_HOST_NAME); > > > > > > > props.put("mail.smtps.auth", "true"); > > > > > > > // props.put("mail.smtps.quitwait", "false"); > > > > > > > > > String from = SMTP_AUTH_USER; > > > > > > > String to = SMTP_AUTH_USER; > > > > > > > String subject = "Testing SMTP-SSL"; > > > > > > > String htmlText = "<h1>Hello</h1><img > src=\"cid:image\">"; > > > > > > > byte[] imgData = this.obtainByteData("enveloppe.gif"); > > > > > > > > > Session mailSession = > Session.getDefaultInstance(props); > > > > > > > mailSession.setDebug(true); > > > > > > > > > Message msg = new MimeMessage(mailSession); > > > > > > > msg.setFrom(new InternetAddress(from)); > > > > > > > msg.addRecipient(Message.RecipientType.TO, new > > > > InternetAddress > > > > > > > (to)); > > > > > > > msg.setSubject(subject); > > > > > > > > > Multipart mp = new MimeMultipart("related"); > > > > > > > > > MimeBodyPart htmlPart = new MimeBodyPart(); > > > > > > > htmlPart.setContent(htmlText, "text/html"); > > > > > > > mp.addBodyPart(htmlPart); > > > > > > > > > MimeBodyPart attachment = new MimeBodyPart(); > > > > > > > attachment.setFileName("test.gif"); > > > > > > > attachment.setContent(imgData, "image/gif"); > > > > > > > attachment.setHeader("Content-ID","<image>"); > > > > > > > mp.addBodyPart(attachment); > > > > > > > > > msg.setContent(mp); > > > > > > > > > Transport transport = mailSession.getTransport(); > > > > > > > > > transport.connect > > > > > > > (SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, > > > > > > > SMTP_AUTH_PWD); > > > > > > > > > transport.sendMessage(msg, > > > > > > > msg.getRecipients(Message.RecipientType.TO)); > > > > > > > > > transport.close(); > > > > > > > } > > > > > > > > > /** > > > > > > > * Constructs a byte array and fills it with data that is > read > > > > > > > from the > > > > > > > * specified resource. > > > > > > > * @param filename the path to the resource > > > > > > > * @return the specified resource as a byte array > > > > > > > * @throws java.io.IOException if the resource cannot be > read, or > > > > > > > the > > > > > > > * bytes cannot be written, or the streams cannot be > closed > > > > > > > */ > > > > > > > private byte[] obtainByteData(String filename) throws > IOException > > > > > > > { > > > > > > > InputStream inputStream = > getClass().getResourceAsStream > > > > > > > (filename); > > > > > > > ByteArrayOutputStream outputStream = new > > > > ByteArrayOutputStream > > > > > > > (1024); > > > > > > > byte[] bytes = new byte[512]; > > > > > > > > > // Read bytes from the input stream in > bytes.length-sized > > > > > > > chunks and write > > > > > > > // them into the output stream > > > > > > > int readBytes; > > > > > > > while ((readBytes = inputStream.read(bytes)) > 0) { > > > > > > > outputStream.write(bytes, 0, readBytes); > > > > > > > } > > > > > > > > > // Convert the contents of the output stream into a > byte > > > > array > > > > > > > byte[] byteData = outputStream.toByteArray(); > > > > > > > > > // Close the streams > > > > > > > inputStream.close(); > > > > > > > outputStream.close(); > > > > > > > > > return byteData; > > > > > > > } > > > > > > > > > } > > > > > > > > > On Nov 18, 11:11 pm, "Ikai L (Google)" <ika...@google.com> > wrote: > > > > > > > > > > What I mean is, is this code working on a different mail > server? > > > > > > > > > > On Wed, Nov 18, 2009 at 2:00 PM, mably <fm2...@mably.com> > wrote: > > > > > > > > > I'm just sending a simple mail from my Gmail account with > an > > > > embedded > > > > > > > > > gif image. > > > > > > > > > > > I can perfectly read it from my mail servlet handler but > when I > > > > try > > > > > > to > > > > > > > > > relay it (cf. code from first message) I get this annoying > > > > > > "Converting > > > > > > > > > attachment data failed" error which seems to be specific to > GAE. > > > > > > > > > > > Here is the mail sent data : > > > > > > > > > > > MIME-Version: 1.0 > > > > > > > > > Sender: x...@gmail.com > > > > > > > > > Received: by 10.142.204.15 with HTTP; Wed, 18 Nov 2009 > 13:57:20 > > > > -0800 > > > > > > > > > (PST) > > > > > > > > > Date: Wed, 18 Nov 2009 22:57:20 +0100 > > > > > > > > > Delivered-To: x...@gmail.com > > > > > > > > > X-Google-Sender-Auth: c9f34852bdb4f249 > > > > > > > > > Message-ID: > > > > > > > > > < > 75c1488c0911181357w4e8efdc2r7e82d8e1c3e03...@mail.gmail.com> > > > > > > > > > Subject: Test > > > > > > > > > From: Francois MASUREL <x...@mably.com> > > > > > > > > > To: contact-test < > contact-t...@webwinewatch.appspotmail.com> > > > > > > > > > Content-Type: multipart/related; > > > > > > boundary=001636e90e61aa516e0478ac5398 > > > > > > > > > > > --001636e90e61aa516e0478ac5398 > > > > > > > > > Content-Type: multipart/alternative; > > > > > > > > > boundary=001636e90e61aa516b0478ac5397 > > > > > > > > > > > --001636e90e61aa516b0478ac5397 > > > > > > > > > Content-Type: text/plain; charset=UTF-8 > > > > > > > > > > > [image: > > > > > > > > > ? > > > > > > > ui=2&view=att&th=125094c9bff3199b&attid=0.1&disp=attd&realattid=ii_125094c9 > bff3199b&zw] > > > > > > > > > > > --001636e90e61aa516b0478ac5397 > > > > > > > > > Content-Type: text/html; charset=UTF-8 > > > > > > > > > Content-Transfer-Encoding:... > > > > plus de détails » > > -- > > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to > google-appengine-j...@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=. > > > -- Ikai Lan Developer Programs Engineer, Google App Engine -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=.