java - How do I send an email with embedded images and regular attachments in JavaMail? -


I would like to know how to create SMTP multipart messages in the correct order so that it render correctly on the iPhone in the mail client (GMail) Correctly rendering).

I am using JavaMail to create an email with the following parts:

  • Content Type "Text / HTML; UTF-8"
  • < Li> An embedded image attachment.
  • A file attachment

I am sending mail (ssl) and mails via Gmail SMTP and a GMail account is used correctly. , However, the mail does not render correctly on the iPhone mail client. On the iPhone Mail client, it should be provided later when the image is provided before the "first image" text. There is an icon with a question mark after the "text" before the text (I suppose it means that this referenced CID can not be found). I'm not sure whether this is a limit to the iPhone Mail client or there is a bug in the code sent to my mail (I believe later).

I think maybe the header on my part may be inaccurate or maybe I'm providing multiparty in the wrong order. I include the text of the received mail as an output by Gmail (the file provides correc

  message-ID: & lt; 3977333klkl274l5402l787kjawamel. Chris@smtp.gmail.com> subject: =? UTF -8? Q? Test_from_ = E3 = 82 = EF = E3 = 83 = AA = E3 = 82 = B9? = Mime-version: 1.0 Content-Type: Multipart / Mixed; C Ma = "---- = _Part_0_20870565.1274154021755" ------ = _ Part_0_20870565.1274154021755 Content-Type: application / octet-stream Content-Transfer-Encoding: base64 Content-ID: & lt; 20100518124021763_368238_0 & gt; Troimd to Aivibioarvatki ----- CONCISENESS 6p1VVy4alAAAAABJRU5ErkJggg == ------ = _ Part_0_20870565.1274154021755 content-type: text / html; charset = UTF -8 content-transfer-encoding: 7bit & lt; html & gt ; Head & gt; & lt; title & gt; Staff favorite foods & lt; / title & gt; & lt; Style & gt; Body (font) Normal 8pt Arial;} {font: bold 8pt aerial; White-space: iPod;} td {font: normal 8pt arial; White-space: nowrap;} & lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; Image & lt; B before r & gt; & Lt; Img src = "cid: 20100518124021763_368238_0" & gt; After the image & lt; Br> & Lt; Table range = "0" & ​​gt; & Lt; TR & gt; & Lt; Th colspan = "4" & gt; Staff favorite foods & lt; / Th & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Th align = "left" & gt; Name & lt; / Th & gt; & Lt; Th align = "left" & gt; Age & lt; / Th & gt; & Lt; Th align = "left" & gt; Telephone number & Lt; / Th & gt; & Lt; Th align = "left" & gt; Fav.Food & lt; / Th & gt; & Lt; / TR & gt; & Lt; Tr style = "background color: # e0e0e0" & gt; & Lt; TD & gt; Chris & lt; / TD & gt; & Lt; TD & gt; 34 & lt; / TD & gt; & Lt; TD & gt; 555-123-4567 & lt; / TD & gt; & Lt; TD & gt; Pancakes & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Body & gt; & Lt; / Html & gt; ------ = _ Part_0_20870565.1274154021755 Content-type: text / plain; Charset us- ascii =; Name = textfile.txt Content-Transfer-Encoding: 7-bit content-dispute: attachment; Filename = textfile.txt This is a text file which is calculated from one to ten below this line: One two three four five six seven eight nine ten (no subsequent train back) ------ = _ Part_0_20870565. 1274154021755--  

Even if you can not help me with this, I would appreciate it that any member of the forum has made me (non-private) Which may include inline images (not images of external hyperlink). I just need to find a work sample, so I can transfer it to the previous one.

Thanks,

Chris.

have you read RFC 2822, which defines the specification requirements for email? I have not read myself through this medium, so I'm not sure that this multi-part mentions the email, but it can be a good place to start. Apple seems very good to paste on the criteria.


Comments