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 閱讀(756) 評論(1)  編輯  收藏 所屬分類: JAVA開發

          Feedback

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

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



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


          網站導航:
           

          My Links

          Blog Stats

          常用鏈接

          留言簿(7)

          隨筆分類(36)

          隨筆檔案(39)

          classmate

          good blog

          企業管理網站

          好友

          站點收藏

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 东乡族自治县| 仁寿县| 凌云县| 博罗县| 徐水县| 偏关县| 富蕴县| 江城| 电白县| 绍兴市| 吴旗县| 新兴县| 盖州市| 内乡县| 平遥县| 淅川县| 米泉市| 宁津县| 马尔康县| 金溪县| 徐州市| 溆浦县| 江油市| 准格尔旗| 许昌市| 开江县| 武山县| SHOW| 德清县| 商丘市| 湘潭市| 长垣县| 宁都县| 诸城市| 滨州市| 芜湖县| 侯马市| 延长县| 永定县| 襄垣县| 阳西县|