<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java學習

    java,spring,structs,hibernate,jsf,ireport,jfreechart,jasperreport,tomcat,jboss -----本博客已經搬家了,新的地址是 http://www.javaly.cn 如果有對文章有任何疑問或者有任何不懂的地方,歡迎到www.javaly.cn (Java樂園)指出,我會盡力幫助解決。一起進步

     

    發郵件代碼

    @Autowired
        private JavaMailSenderImpl  mailSender;

        /**請求處理并發送email*/
        @RequestMapping("/doRequestAndSendMail.shtml")
        public String doRequestAndSendMail(ModelMap model,HttpServletRequest request,
                HttpServletResponse response) throws Exception{
    。。。。。
            //發送郵件
            String email = request.getParameter("email");
            if(null != email )
                if(!email.equals(""))
                    this.sendMail(email, delivery.getFeedbackPath(),request.getParameter("feedback"));
    。。。。

    }

        /**發送郵件*/
        private void sendMail(String email,String accessoryPath,String feedback){
                JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();   
                MimeMessage mailMessage = senderImpl.createMimeMessage();   
              try {
                //設置utf-8或GBK編碼,否則郵件會有亂碼
                MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage,true,"utf-8");
                messageHelper.setTo(email);//接受者      
                  // messageHelper.setFrom("");//發送者   
                   messageHelper.setSubject("華為");//主題   
                   //郵件內容,注意加參數true   
                   /**如果沒有填寫反饋文字,則使用默認 */
                   if(null != feedback ){
                       if(!feedback.equals(""))
                           messageHelper.setText("<html><head></head><body><h1>"+feedback+"</h1></body>< ml>",true);
                   }
                      
                   //郵件嵌入圖片  
                   //messageHelper.addInline("a", new File("E:/xiezi.jpg"));   
                   //messageHelper.addInline("b", new File("E:/logo.png"));    
                   //File file=new File("E:/測試中文文件.rar");
                   if(null != accessoryPath ){
                       if(!accessoryPath.equals("")){
                           System.out.println("發送的附件來自于:"+accessoryPath);
                           File file=new File(accessoryPath);
                           // 這里的方法調用和插入圖片是不同的,使用MimeUtility.encodeWord()來解決附件名稱的中文問題   
                           messageHelper.addAttachment(MimeUtility.encodeWord(file.getName()), file);
                       }
                   }
                   mailSender.send(mailMessage);
                   
            } catch (MessagingException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }   
        }

    posted on 2009-06-22 10:23 找個美女做老婆 閱讀(219) 評論(0)  編輯  收藏


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


    網站導航:
     

    導航

    統計

    公告

    本blog已經搬到新家了, 新家:www.javaly.cn
     http://www.javaly.cn

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 台湾一级毛片永久免费| 18禁止观看免费私人影院| 两个人看的www免费视频| 成年人视频免费在线观看| 免费成人黄色大片| 亚洲人成777在线播放| 日韩色日韩视频亚洲网站| 国产一级高青免费| 好爽…又高潮了免费毛片| 亚洲精品无码久久一线| 亚洲熟妇AV日韩熟妇在线| 在线观看免费无码视频| 免费在线观看黄网站| 亚洲小说图片视频| 国产成人免费视频| 久久99亚洲综合精品首页| 亚洲人成在线中文字幕| 亚洲av无码成人精品区在线播放| 亚洲av无码成人黄网站在线观看 | 日本免费网址大全在线观看| 日本亚洲视频在线| 亚洲综合色丁香婷婷六月图片| 精品一区二区三区无码免费直播| h片在线免费观看| 亚洲AV成人无码久久精品老人| 久久久久免费看成人影片| xxxxx做受大片视频免费| 边摸边吃奶边做爽免费视频99 | 国产AV无码专区亚洲AWWW| 无码欧精品亚洲日韩一区夜夜嗨 | 国产免费一区二区视频| 亚洲自偷自偷图片| 国产性生大片免费观看性| 亚洲AV无码一区二区三区在线观看 | 91精品国产免费网站| 久久精品国产亚洲av麻豆小说| 精品视频一区二区三区免费| 亚洲午夜国产精品无码 | 国产精品亚洲综合久久| 日韩一区二区三区免费体验| 高清免费久久午夜精品|