Java Mail·¢ËÍ´øÓÐͼƬµÄhtml¸ñʽµÄÓʼþ
Java Mail·¢ËÍ´øÓÐͼƬµÄhtml¸ñʽµÄÓʼþ£¬Õë¶ÔÓÚÏÔʾͼƬ£¬Ò»°ãÓÐÁ½ÖÖ·½·¨¡£
1. ͼƬ´æÔÚÓÚ·þÎñÆ÷ÉÏ£¬ÎÒÃÇÖ»ÐèÒª°ÑͼƬÔÚ·þÎñÆ÷µÄµÄÁ´½Ó·Å½øÈ¥¼´¿É¡£
ÕâÖÖ·¢Ê½±È½Ï¼òµ¥£¬µ«ÊÇÕâÖÖ·½·¨ÓÐЩȱÏÝ£º
ͼƬ²»Ö§³ÖÀëÏßä¯ÀÀ£»
ÿ´Îä¯ÀÀÓʼþÐèÒª·ÃÎÊweb·þÎñ£¬Ôö¼Ó·þÎñÆ÷¸ºµ££»
ÈôͼƬÒÔ¶þ½øÖƵķ½Ê½´æÔÚÓÚÊý¾Ý¿â»òÊǶ¯Ì¬Éú³ÉµÄ£¬ÔòÎÞ·¨ÓÐЧµÄ½â¾ö¡£
2. °ÑͼƬÒÔ¸½¼þµÄ·½Ê½·¢ËͳöÈ¥£¬ÕâÖÖ·½Ê½·Ç³£ÊÊÓÃÓÚͼƬ´æÔÚÓÚÊý¾Ý¿âÖеÄÇé¿ö¡£
±¾ÎÄÒ²Ö÷ÒªÌÖÂÛÕâÖÖÇé¿ö¡£
¶ÔÓÚJava MailµÄ»ù´¡ÖªÊ¶£¬Çë¿´http://www.yesky.com/SoftChannel/72348977504190464/20020713/1620276.shtml£¬
±¾ÎIJ»×÷½éÉÜÁË¡£
˵µ½ÓʼþÖеĸ½¼þ£¬ÎÒ²»µÃ²»ËµÒ»ËµMiniMultipartÀ࣬ÌṩÁËÔÚÓʼþÖмÓÈ븽¼ÓµÄʵÏÖ·½·¨¡£
Ò»¸ö¶à²¿·ÖÓʼþÊÇÒ»¸öÄÚÈÝÀàÐÍ£¨content-type£©±»ÉèÖÃΪMiniMultipartµÄMessage¶ÔÏó¡£
MiniMultipartÀàÊÇÒ»¸öÈÝÆ÷À࣬°üº¬MimeBodyPartÀàÐ͵ĶÔÏó¡£
ÎÒÃÇ¿ÉÒÔÓÃÒ»¸öMimeBodyPart°üº¬htmlÔ´´úÂ룬ÆäËûµÄMimeBodyPart°üº¬¶þ½øÖƵÄͼƬ¸½¼þ¡£
µ«ÊÇÕâÀïÓиöÒâÍâÇé¿ö£¬ÎÒÃÇÏÈ¿´MimeBodyPartµÄ³õʼ»¯´úÂ룺
MimeBodyPart mdp = new MimeBodyPart(); //н¨Ò»¸ö´æ·Å¸½¼þµÄBodyPart
DataHandler dh = new DataHandler(...);
mdp.setDataHandler(dh); //¸øBodyPart¶ÔÏóÉèÖÃÄÚÈÝΪdh
ÆäÖе±DataHandler³õʼ»¯Ê±ÐèÒªDataSourceµÄ×ÓÀà
/** from JDK Doc */
public DataHandler(DataSource ds)
Create a DataHandler instance referencing the specified DataSource.
The data exists in a byte stream form. The DataSource will provide an InputStream to access the data.
Parameters:ds - the DataSource
ÔÚJDK1.4ÖУ¬DataSourceÊǸöInterface,DataSource½öÓÐMimePartDataSource, URLDataSource, FileDataSourceÈý¸ö×ÓÀ࣬
¶øÔÚÕâÈý¸öÀàÖÐûÓÐÒ»¸öÄÜÖ±½ÓÓöþ½øÖÆÁ÷(byte[])´´½¨ÊµÀý¡£µ±È»ÎÒÃÇ¿ÉÒÔ°ÑÄÚ´æÖеĶþ½øÖÆÁ÷дµ½ÎļþÖУ¬ÔÙÈÃFileDataSource¶Á½øÀ´¡£
µ«ÊÇÕâÑù»á¸ø·þÎñÆ÷´øÀ´¶øÍâµÄÓ²Å̶Áд£¬Èô²Ù×÷Ƶ·±£¬»áÔì³É·þÎñÆ÷ÐÔÄÜϽµ¡£ÐÒÔ˵ÄÊÇÎÒÔÙÍøÉÏ·¢ÏÖÁËÕâôһ¸öÀ࣬¿ÉÒÔÖ±½ÓÓöþ½øÖÆÁ÷Ö±½Ó´´½¨ÊµÀý¡£
import java.io.*;
import javax.activation.*;
public class ByteArrayDataSource implements DataSource
{
/*** Data to write. */
private byte[] _data;
/*** Content-Type. */
private String _type;
/* Create a datasource from an
Ïà¹ØÎĵµ£º
Â¥Ö÷·¢±íÓÚ£º2008-06-17 15:26:20
l JBS
1.Áоٳö 10¸öJAVAÓïÑÔµÄÓÅÊÆ
a:Ãâ·Ñ£¬¿ªÔ´£¬¿çƽ̨(ƽ̨¶ÀÁ¢ÐÔ)£¬¼òµ¥Ò×Ó㬹¦ÄÜÍêÉÆ£¬ÃæÏò¶ÔÏ󣬽¡×³ÐÔ£¬¶àỊ̈߳¬½á¹¹ÖÐÁ¢£¬ÆóÒµÓ¦ÓõijÉÊìƽ̨, ÎÞÏßÓ¦ÓÃ
2.ÁоٳöJAVAÖÐ10¸öÃæÏò¶ÔÏó±à³ÌµÄÊõÓï
a:°ü£¬À࣬½Ó¿Ú£¬¶ÔÏó£¬ÊôÐÔ£¬·½·¨£¬¹¹ÔìÆ÷ ......
×î½üµÄDevoxx´ó»áÉÏ£¬Java 7½«°üº¬±Õ°üµÄÏûÏ¢ÁîºÜ¶àÈ˸е½Õñ·Ü——Õ⽫×öΪһ¸ö¶ÀÁ¢µÄJSR±»ÊµÏÖ¡£ÔÚÖÚ¶àJava 7еÄÓïÑÔÌØÐÔÖУ¬ÓÐһЩÏÖÔÚÒѾÍê³ÉÁË¡£Devoxx´ó»áµÄһλ²Î»áÕßÔÚ²©¿ÍÖб¨¸æÁËÏÂÃæÕâЩJava 7ÒѾÍê³ÉµÄ7´óй¦ÄÜ£º
1£©¶Ô¼¯ºÏÀàµÄÓïÑÔÖ§³Ö£»
2£©×Ô¶¯×ÊÔ´¹ÜÀí£»
3£©¸Ä½øµÄͨÓÃʵÀý´´½¨ÀàÐÍÍ ......
java³ÌÐòÄÚ´æÖ÷Òª·ÖΪÁË2¸ö²¿·Ö£¬°üÀ¨ stack segment(Õ»ÄÚ´æ)¡¢heap segment(¶ÑÄÚ´æ)¡£
ÔÚ·ÖÎöJava³ÌÐòÄÚ´æ·ÖÅäÇé¿öʱ£¬ÎÒÃÇ´ÓÏÂÃæÕâ¸ö¾³£±»Ê¹ÓõÄÀý×Ó¿ªÊ¼°É¡£
ÏÂÃæ³ÌÐò½«´òӡʲôÄØ£¿
Java´úÂë
String s1&nbs ......
¾¡¹ÜÔƼÆËãÕâÒ»ÊõÓï²¢²»ÐÂÏÊ(AmazonÔÚ2006Äê¾Í¿ªÊ¼ÌṩËüµÄÔÆ·þÎñ)£¬µ«´Ó2008ÄêÆðËü²Å¿ªÊ¼ÕæÕý³ÉΪÁ÷Ðдʣ¬ÕâÆڼ䣬GoogleºÍ
AmazonµÄÔÆ·þÎñÖð½¥»ñµÃÁ˹«ÖڵĹØ×¢¡£ GoogleµÄApp EngineʹÓû§Äܹ»ÔÚGoogle»ù´¡ÉèÊ©ÉϹ¹½¨ºÍÍÐ¹Ü Web Ó¦ÓóÌÐò¡£
¡¡¡¡Á¬Í¬S3£¬AmazonWeb Services»¹°üÀ¨Elastic Cloud Compute
(EC2) ......
±¾ÎĽéÉÜÁËJavaÄÚ´æÒç³öµÄÏêϸ½â¾ö·½°¸¡£±¾ÎÄ×ܽáÄÚ´æÒç³öÖ÷ÒªÓÐÁ½ÖÖÇé¿ö£¬¶øJVM¾³£µ÷ÓÃÀ¬»ø»ØÊÕÆ÷½â¾öÄÚ´æ¶Ñ²»×ãµÄÎÊÌ⣬µ«ÊÇÓÐʱÈÔ»áÓÐÄÚ´æ²»×ãµÄ´íÎó¡£×÷Õß·ÖÎöÁËJVMÄÚ´æÇøÓò×é³É¼°JVMÉèÖÃÐéÄâÄÚ´æµÄ·½Ê½£¬´Ó¶ø¸ø³öÁËһϵÁнâ¾ö·½°¸¡£ Ò»¡¢ÄÚ´æÒç³öÀàÐÍ 1¡¢java.lang.OutOfMemoryError: PermGen space JVM¹ ......