javajohn

          金色年華

          郵件發送之-----------超簡單版

             public static void sendMail(String from,String to,String host,String text,String subject){
                 
          try
                     Properties props 
          = new Properties(); 
                     Session sendMailSession; 
                     Store store; 
                     Transport transport; 
                     sendMailSession 
          = Session.getInstance(props, null); 
                     props.put(
          "mail.smtp.host""郵件服務器"); 
                     Message newMessage 
          = new MimeMessage(sendMailSession); 
                     newMessage.setFrom(
          new InternetAddress(from)); 
                     newMessage.setRecipient(Message.RecipientType.TO, 
          new InternetAddress(to)); 
                     newMessage.setSubject(subject); 
                     newMessage.setSentDate(
          new Date()); 
                     newMessage.setText(text); 
                     transport 
          = sendMailSession.getTransport("smtp"); 
                     transport.send(newMessage);                         
                    }
          catch(MessagingException m){ 
                     System.out.println(m.toString()); 
                 } 
             }

          posted on 2005-12-15 16:28 javajohn 閱讀(764) 評論(1)  編輯  收藏 所屬分類: JAVA開發

          Feedback

          # re: 郵件發送之-----------超簡單版 2006-07-06 17:33 純凈水

          不用設用戶名和密碼的?  回復  更多評論   



          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          My Links

          Blog Stats

          常用鏈接

          留言簿(7)

          隨筆分類(36)

          隨筆檔案(39)

          classmate

          good blog

          企業管理網站

          好友

          站點收藏

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 新安县| 佛坪县| 乌鲁木齐县| 博乐市| 沙洋县| 虎林市| 金平| 江源县| 新津县| 昌平区| 辉南县| 沈丘县| 林芝县| 永宁县| 景谷| 昌江| 延安市| 大足县| 师宗县| 松潘县| 上饶县| 湖口县| 南宫市| 古浪县| 竹山县| 含山县| 温泉县| 隆安县| 文安县| 大渡口区| 新干县| 巫溪县| 巴林左旗| 保靖县| 曲水县| 通州区| 丰县| 广东省| 桑日县| 黄陵县| 河西区|