javajohn

          金色年華

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

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

          Feedback

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

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



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


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

          My Links

          Blog Stats

          常用鏈接

          留言簿(7)

          隨筆分類(36)

          隨筆檔案(39)

          classmate

          good blog

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

          好友

          站點(diǎn)收藏

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 宜良县| 大邑县| 丰都县| 临海市| 安庆市| 印江| 扎囊县| 横山县| 靖宇县| 武陟县| 秭归县| 桑植县| 廉江市| 武夷山市| 南开区| 来宾市| 本溪市| 扶绥县| 岳西县| 台东市| 临海市| 大理市| 新巴尔虎左旗| 锡林浩特市| 张家界市| 靖边县| 锦州市| 永修县| 新兴县| 广南县| 贺兰县| 三江| 福泉市| 来宾市| 炉霍县| 彭山县| 安仁县| 都昌县| 迁西县| 湾仔区| 开封市|