javajohn

          金色年華

          郵件發(fā)送之-----------超簡單版

             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""郵件服務(wù)器"); 
                     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開發(fā)

          Feedback

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

          不用設(shè)用戶名和密碼的?  回復(fù)  更多評論   



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


          網(wǎng)站導(dǎo)航:
           

          My Links

          Blog Stats

          常用鏈接

          留言簿(7)

          隨筆分類(36)

          隨筆檔案(39)

          classmate

          good blog

          企業(yè)管理網(wǎng)站

          好友

          站點收藏

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 儋州市| 玉山县| 三门峡市| 仁化县| 彝良县| 小金县| 庆云县| 潞城市| 都兰县| 崇明县| 边坝县| 深州市| 肇州县| 清涧县| 泾川县| 吉林市| 榆社县| 汽车| 繁峙县| 凤山市| 镇沅| 通江县| 平和县| 保德县| 镇坪县| 遂川县| 太仆寺旗| 伊宁县| 谷城县| 肇东市| 隆安县| 盐山县| 霞浦县| 宜川县| 浑源县| 衢州市| 烟台市| 孝感市| 远安县| 洪雅县| 甘洛县|