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
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
// Socket1.cpp : ¶¨Òå¿ØÖÆ̨ӦÓóÌÐòµÄÈë¿Úµã¡£
//
#include "stdafx.h"
#include<winsock.h>
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
#define WSWENS MAKEWORD(2,0)
int _tmain(int argc, _TCHAR* argv[])
{
sockaddr_in sin; ......
javaÉÏ´«Îļþ
ÐèÒªµÄµÚÈý·½jar°üÓУ¨ÕâÀïʹÓÃapacheµÄ£©
apacheµÄcommons-fileupload£¨ÉÏ´«Óã©£¬commons-io £¨listenerÇåÀíÀàÓã© £¬ commons-beanutils£¨¿ÉÑ¡£©
¾ßÌå²Ù×÷
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUp ......
×î½üµÄDevoxx´ó»áÉÏ£¬Java 7½«°üº¬±Õ°üµÄÏûÏ¢ÁîºÜ¶àÈ˸е½Õñ·Ü——Õ⽫×öΪһ¸ö¶ÀÁ¢µÄJSR±»ÊµÏÖ¡£ÔÚÖÚ¶àJava 7еÄÓïÑÔÌØÐÔÖУ¬ÓÐһЩÏÖÔÚÒѾÍê³ÉÁË¡£Devoxx´ó»áµÄһλ²Î»áÕßÔÚ²©¿ÍÖб¨¸æÁËÏÂÃæÕâЩJava 7ÒѾÍê³ÉµÄ7´óй¦ÄÜ£º
1£©¶Ô¼¯ºÏÀàµÄÓïÑÔÖ§³Ö£»
2£©×Ô¶¯×ÊÔ´¹ÜÀí£»
3£©¸Ä½øµÄͨÓÃʵÀý´´½¨ÀàÐÍÍ ......
ÎÒ¸Õ´ÓÔÚAntwerpÕÙ¿ªµÄDevoxx
´ó»áÉÏ»ØÀ´£¬»áÉϽéÉÜÁËJava7µÄÐÂÌØÐÔ£¬¶ÔÓ¦µÄJDK½«ÓÚ2010Äê9Ô·¢²¼¡£
ÏÂÃæÊÇ7¸öÒѾÍê³ÉµÄÐÂÌØÐÔ£º
¶ÔcollectionsµÄÓïÑÔ¼¶Ö§³Ö
×Ô¶¯×ÊÔ´¹ÜÀí
¸Ä½ø·ºÐÍÔÚ´´½¨ÊµÀýʱµÄÀàÐÍÒýÓÃ
´øÏ»®ÏßµÄÊý×Ö
ÔÚswitchÖÐʹÓÃString
¶þ½øÖÆÎÄ×Ö
¼ò»¯µÄ¿É±ä²ÎÊý·½·¨µ÷ÓÃ
Java7»¹ÓкܶàÆäËûµÄÐ ......