这个问题还差不多。
我觉得只要你能够发送文本格式的文件,只要将哪些内容用HTML语言做一下规划一同发出去,应该是可以的。不过,我没有测试过,个人观点,希望大家批判。

解决方案 »

  1.   

    这个问题早问过了.
    String msgText=getHtmlMessageText(...);
    msg.setContent(msgText,"text/html");
      

  2.   


    /**
    发送Email 的JavaBean@author sharetop
    @version 1.0.1
    created date:2001-4-25采用直接写Socket方式发送email
    关于SMTP(SIMPLE MAIL TRANSFER PROTOCOL)命令,
    参考 http://www.faqs.org/rfcs/rfc821.html*/import java.io.*;
    import java.util.*;
    import java.net.*;public class Email
    {
      private static final String CONTENT_TYPE = "text/html";  private String smtpServer=null;
      private String fromMail=null;
      private String toMail=null;
      
      public Email(String smtp,String from,String to)
      {
       this.smtpServer=smtp;
       this.fromMail=from;
       this.toMail=to;
      }
      
      public void mail(String subject,String content) throws MailException
      {    try{
      
       //打开邮件服务器port:25
       Socket s = new Socket(smtpServer,25);
      
       //用于socket读写数据
       PrintWriter out = new PrintWriter(s.getOutputStream(),true);
       BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
        
         String res = null; //smtp服务器返回信息     out.println("HELO "+smtpServer);
    res=in.readLine();
    if( !res.startsWith("220") ) throw new MailException("MailException:"+res);

        out.println("MAIL FROM: "+fromMail);
         res = in.readLine();
         if( !res.startsWith("250") ) throw new MailException("MailException:"+res);   out.println("RCPT TO: "+toMail);
         res = in.readLine();
        if( !res.startsWith("250") ) throw new MailException("MailException:"+res);

        out.println("DATA");
         res = in.readLine();
         if( !res.startsWith("250") ) throw new MailException("MailException:"+res);
        
        out.println("Subject:"+subject);
        out.println("From:"+fromMail);
        out.println("To:"+toMail);
         out.println("Content-Type: text/html; charset=gb2312");
         out.println(content);     out.println(".");
        res = in.readLine();
    if( !res.startsWith("354") ) throw new MailException("MailException:"+res);
        
    out.println("QUIT");
         s.close();
       }
        catch(UnknownHostException x) {
       throw new MailException("MailException:"+x.getMessage());
       }
       catch(IOException x){
       throw new MailException("MailException:"+x.getMessage());
       }
     }//end method mail}//end class Email//发送邮件违例类
    class MailException extends Exception
    {
    public MailException(String msg)
    {
    super(msg);
    }
    }
    给分吧,我的分太少了!!!!!!
      

  3.   


    没问题了我一直用的一个Bean了。不过不能发附件而已。快给分吧,我饿死了。
      

  4.   


    再给一个例子吧:
    import java.io.*;
    import java.util.*;
    import java.net.*;public class test
    {
      
      public static void main(String[] args)
      {
      try{
    Email em = new Email("smtp.21cn.com","[email protected]","[email protected]");
    em.mail("测试邮件","<font color=blue>我在北京</font>");
    System.out.println("ok");
    }
    catch(Exception e){
    e.printStackTrace(System.err);
    }
      }
      
    }
      

  5.   


    to xiaoyou(三尺剑):不好意思,我是去分多,进分少,唉!日子难过呀。你有分转让,我当然是来者不拒了^_^
      

  6.   

    请来这里领分:http://www.csdn.net/expert/topic/165/165232.shtm