我想知道如何以正確的順序構建SMTP多部分郵件,以便它將在iPhone郵件客戶端上正確呈現(在GMail中正確呈現)。如何在JavaMail中發送包含嵌入式圖像和常規附件的電子郵件?
我使用JAVAMAIL建立含有下列部分的電子郵件:
- 身體部分與內容類型 「text/html的; UTF-8」
- 嵌入圖像附件。
- 文件附件
我(通過SSL)通過Gmail SMTP發送郵件和發送郵件,並使用Gmail帳戶正確呈現,但是,郵件不正確的iPhone郵件客戶端上呈現。在iPhone郵件客戶端上,圖像在「之前圖像」文本之前呈現,之後應呈現該圖像。在「Before Image」文本之後,有一個帶有問號的圖標(我認爲這意味着它無法找到引用的CID)。我不確定這是否是iPhone郵件客戶端的限制或我的郵件發送代碼中的錯誤(我強烈假定後者)。
我認爲也許我的零件上的標題可能不正確,或者我提供的順序錯誤的多部分。包括我收到的郵件是Gmail的文本輸出(這使得該文件correc
Message-ID: <[email protected]>
Subject: =?UTF-8?Q?Test_from_=E3=82=AF=E3=83=AA=E3=82=B9?=
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_20870565.1274154021755"
------=_Part_0_20870565.1274154021755
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-ID: <20100518124021763_368238_0>
iVBORw0K ----- TRIMMED FOR CONCISENESS
6p1VVy4alAAAAABJRU5ErkJggg==
------=_Part_0_20870565.1274154021755
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<html><head><title>Employees Favourite Foods</title>
<style>
body { font: normal 8pt arial; }
th { font: bold 8pt arial; white-space: nowrap; }
td { font: normal 8pt arial; white-space: nowrap; }
</style></head><body>
Before Image<br><img src="cid:20100518124021763_368238_0">
After Image<br><table border="0">
<tr>
<th colspan="4">Employees Favourite Foods</th>
</tr>
<tr>
<th align="left">Name</th><th align="left">Age</th><th align="left">Tel.No</th><th align="left">Fav.Food</th>
</tr>
<tr style="background-color:#e0e0e0">
<td>Chris</td><td>34</td><td>555-123-4567</td><td>Pancakes</td>
</tr>
</table></body></html>
------=_Part_0_20870565.1274154021755
Content-Type: text/plain; charset=us-ascii; name=textfile.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=textfile.txt
This is a textfile with numbers counting from one to ten beneath this line:
one
two
three
four
five
six
seven
eight
nine
ten(no trailing carriage return)
------=_Part_0_20870565.1274154021755--
即使你不能與此幫助我,我將不勝感激,如果論壇的任何成員可以轉發我(非個人)的郵件,包括內嵌圖像(不是外部超鏈接的圖像,雖然)。我只需要找到一個工作的樣品,然後我可以搬過去這一點。
感謝,
克里斯。