Ejemplo n.º 1
0
  @Test
  public void test() {
    BaseApplicationContext context =
        DefaultApplicationContext.getApplicationContext("com/sany/mail/property-mail.xml");
    SendMail sendMail = context.getTBeanObject("sendMail", SendMail.class);
    sendMail.sendTextMail(new String[] {"*****@*****.**"}, "你好", "很好,很强大!");
    String content =
        " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"96\">"
            + "<tr>"
            + "<td width=\"24%\" height=\"94\"><a href='http://ippresource.sany.com.cn/qikan/html/2013-04/29/node_1.htm' target='_blank'><img width='80' height='90' border='0' src='uploadfiles/201207/20120731060411867.jpg'></a></td>"
            + "<td width=\"76%\" valign=\"top\"><div><strong>三一集团报</strong></div>"
            + "<div><span class=\"red\">三一集团报</span> <a href=\"javascript:void('0')\" onclick=\"showPdf('http://ippresource.sany.com.cn/qikan/html/2013-04/29/node_1.htm')\">浏览</a>|<a href='brands/magazine/default.htm' target='_blank'>更多 >></a></div>"
            + "<div>做一流企业,办一流企业报。《三一集团》报1999年创刊,它见证记载了三一发展的艰辛和辉煌。</div></td>"
            + "</tr>"
            + "</table>";

    sendMail.sendHtmlMail(new String[] {"*****@*****.**"}, "你好html", content);
    sendMail.sendAttach(
        new String[] {"*****@*****.**"},
        "你好html",
        content,
        new String[] {
          "D:\\workspace\\SanyPDP\\resources\\org\\frameworkset\\task\\quarts-task.xml"
        });
  }
Ejemplo n.º 2
0
 public static void sendMail(String subject, String content, String format) {
   MailSenderInfo mailInfo = new MailSenderInfo();
   mailInfo.setMailServerHost("sl2k8mail-01.dangdang.com");
   mailInfo.setMailServerPort("587");
   mailInfo.setValidate(true);
   mailInfo.setUserName("*****@*****.**");
   mailInfo.setPassword("Sl-1234"); // 您的邮箱密码
   mailInfo.setFromAddress("*****@*****.**");
   mailInfo.setToAddress("*****@*****.**");
   //	     mailInfo.setCcAddress("*****@*****.**");
   //	     mailInfo.setCcAddress("[email protected]; [email protected]");
   //	     mailInfo.setBccAddress("*****@*****.**");
   mailInfo.setSubject(subject);
   mailInfo.setContent(content);
   SendMail sms = new SendMail();
   if (format.equals("TEXT")) {
     sms.sendTextMail(mailInfo); // 发送文体格式
   } else if (format.equals("HTML")) {
     sms.sendHtmlMail(mailInfo); // 发送html格式
   }
 }