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 閱讀(764) 評(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)論排行榜

          主站蜘蛛池模板: 临澧县| 广昌县| 乐陵市| 阿拉善左旗| 梓潼县| 石首市| 大城县| 海门市| 宜都市| 宾阳县| 会泽县| 通渭县| 昌都县| 九龙城区| 金平| 女性| 娱乐| 和政县| 兴义市| 增城市| 赤壁市| 农安县| 称多县| 阿坝县| 广河县| 潮州市| 卢龙县| 迭部县| 龙海市| 甘肃省| 黄浦区| 景洪市| 南京市| 皋兰县| 望都县| 平潭县| 吉水县| 汕尾市| 安岳县| 康定县| 扎囊县|