老妖的博客
          現實的中沒有幾個人能夠真為對方去死,甚至山盟海誓很快就會在金錢面前變的微不足道,這才是生活。沒有永遠的愛,除了你的父母對你,當然也就沒有永遠的恨,更沒有永遠的痛,時間是最好的治療大師,它會很快撫平你心靈上累累的傷痕。很多年以后你想起來時,那些在你生命中洶涌來往的人群至多是個模糊的影子或者毫無意義的名字
          posts - 105,  comments - 171,  trackbacks - 0
           1 package com.educast.mail;
           2 
           3 import org.springframework.mail.javamail.MimeMessageHelper;
           4 import org.springframework.context.ApplicationContext;
           5 import org.springframework.context.support.FileSystemXmlApplicationContext;
           6 import org.springframework.core.io.FileSystemResource;
           7 
           8 import javax.mail.internet.MimeMessage;
           9 import javax.mail.MessagingException;
          10 import java.io.File;
          11 
          12 public class ImageMailSender extends BaseMailSender {
          13         public void sendMessage() throws MessagingException {
          14         MimeMessage msg = sender.createMimeMessage();
          15         MimeMessageHelper helper = new MimeMessageHelper(msg, true"GB2312");
          16 
          17         helper.setTo(to);
          18         helper.setFrom(from);
          19         helper.setSubject(subject);
          20 
          21         helper.setText("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"></head><body><h1><a href='#'>郁悶!"
          22                 + "<img src=\"cid:img\"></body></html>"true);
          23 
          24         // add the image
          25         FileSystemResource image = new FileSystemResource(new File(
          26                 "c:\\0.gif"));
          27         helper.addInline("img", image);
          28 
          29         sender.send(msg);
          30     }
          31 
          32     public static void main(String[] args) throws Exception {
          33        ApplicationContext ctx = new FileSystemXmlApplicationContext(
          34     new String[] { "D:\\WORK\\JDBC\\mail\\src\\javaMailSender.xml" });
          35         ImageMailSender sender = (ImageMailSender) ctx.getBean("messageSender");
          36         sender.sendMessage();
          37     }
          38 }
          39 
          40 
           1 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
           2 <beans>
           3  <bean id="sender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
           4   <property name="host">
           5    <value>localhost</value>
           6   </property>
           7   <property name="username">
           8    <value>webmaster</value>
           9   </property>
          10   <property name="password">
          11    <value>password</value>
          12   </property>
          13         <property name="javaMailProperties">
          14         <props>
          15         <prop key="mail.smtp.auth">true</prop>
          16         </props>
          17         </property>
          18 
          19     </bean>
          20 
          21  <bean id="messageSender" class="com.educast.mail.ImageMailSender">
          22   <property name="javaMailSender">
          23    <ref bean="sender"/>
          24   </property>
          25   <property name="to">
          26    <value>mfc42d@163.com</value>
          27   </property>
          28   <property name="from">
          29    <value>webmaster@mymail.cn</value>
          30   </property>
          31   <property name="subject">
          32    <value>HTML Mail</value>
          33   </property>
          34  </bean>
          35 </beans>
          36 
          37 
          posted on 2005-11-03 19:41 老妖 閱讀(1054) 評論(0)  編輯  收藏 所屬分類: spring

          <2005年11月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          常用鏈接

          隨筆分類(48)

          隨筆檔案(104)

          好友鏈接

          我的豆瓣

          積分與排名

          • 積分 - 221096
          • 排名 - 257

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 芜湖县| 昭觉县| 台湾省| 托克托县| 南丹县| 阜新市| 浦北县| 南江县| 个旧市| 鄢陵县| 石河子市| 天峻县| 武定县| 宁都县| 东海县| 宁武县| 阳朔县| 锡林浩特市| 衡南县| 盘山县| 博白县| 岚皋县| 齐齐哈尔市| 富民县| 沧州市| 青浦区| 利津县| 天全县| 中西区| 肥西县| 南雄市| 城固县| 乌恰县| 酒泉市| 抚顺县| 藁城市| 横山县| 石阡县| 平乐县| 桐柏县| 鸡东县|