《pro Spring》学习笔记之使用Spring+James邮件服务器发送内嵌图片的HTML邮件
2007-09-14 16:59
831 查看
首先,请参考这一片文章,配置好James邮件服务器
http://blog.csdn.net/daryl715/archive/2007/09/14/1784869.aspx
为了发送一副内嵌图片的HTML的电子邮件,你必须先组装html消息,然后再把图片作为mime的消息额外部分添加进去,再添加一个 mime部分时,你可以先给他关联一个Content-id,一个Content-id是来在html里引用图片的,在使用MimeMessageHelper时候,spring帮你处理了这个过程后的很逻辑
抽象类:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ch15.SimplePicMail;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.mail.javamail.JavaMailSenderImpl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public abstract class AbstractMessageSender ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String to;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String from;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String subject;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected JavaMailSenderImpl sender;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getTo() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return to;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setTo(String to) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.to = to;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getFrom() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return from;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setFrom(String from) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.from = from;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getSubject() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return subject;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setSubject(String subject) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.subject = subject;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getText() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setText(String text) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.text = text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public JavaMailSenderImpl getSender() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return sender;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setSender(JavaMailSenderImpl sender) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.sender = sender;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
实现类:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ch15.SimplePicMail;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import javax.mail.MessagingException;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import javax.mail.internet.MimeMessage;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.core.io.FileSystemResource;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.mail.javamail.MimeMessageHelper;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class SimplePICMessageSender extends AbstractMessageSender ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private MimeMessageHelper helper;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private MimeMessage msg;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private FileSystemResource img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public FileSystemResource getImg() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setImg(FileSystemResource img) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.img = img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void sendMessage()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
msg=sender.createMimeMessage();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
try ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper=new MimeMessageHelper(msg,true); //使用内嵌资源时,需要额外配置一个true参数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setTo(to);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setFrom(from);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setSubject(subject);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setText(text,true);//true表示text/html格式邮件
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.addInline("abc", img); //加入一个名为abc的内嵌资源
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(img);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
}catch (MessagingException e) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(e.getMessage());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sender.send(msg);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
配置文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<?xml version="1.0" encoding="UTF-8"?>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<beans
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
xmlns="http://www.springframework.org/schema/beans"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean id="sender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="host">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>king.cn</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="username">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>gaoxiang</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="password">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>gaoxiang</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="javaMailProperties">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<props>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<prop key="mail.smtp.auth">true</prop>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<prop key="mail.smtp.timeout">10000</prop>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</props>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean id="messageSender" class="ch15.SimplePicMail.SimplePICMessageSender">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="sender">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<ref bean="sender"/>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="to">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>daryl715@tom.com</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="from">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>gaoxiang@king.cn</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="subject">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>html mime mail</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!-- 此处用cid:abc 表示实用的一个内嵌资源,名称为abc -->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="text">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value><![CDATA[<html><head><body>this is a pic mail<img src="cid:abc"></body></head></html>]]></value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="img">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean class="org.springframework.core.io.FileSystemResource">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean class="java.io.File">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>./src/ch15/SimplePicMail/mail.jpg</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</beans>
测试代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ch15.SimplePicMail;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import java.io.File;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.context.ApplicationContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.context.support.ClassPathXmlApplicationContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class SimplePICTest ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public static void main(String[] args) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ApplicationContext context=new ClassPathXmlApplicationContext("ch15/SimplePicMail/applicationContext.xml");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SimplePICMessageSender mailSender=(SimplePICMessageSender)context.getBean("messageSender");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
for (int i = 0; i < 10; i++) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
mailSender.sendMessage();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println("成功");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Thread.sleep(2000); //发送后延时2秒钟
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
总体来说,最好避免使用内嵌图片,而使用url来访问图片,许多电子邮件客户端对内嵌图片支持有一定的问题,尤其是当他们组成像“复杂mime”时
http://blog.csdn.net/daryl715/archive/2007/09/14/1784869.aspx
为了发送一副内嵌图片的HTML的电子邮件,你必须先组装html消息,然后再把图片作为mime的消息额外部分添加进去,再添加一个 mime部分时,你可以先给他关联一个Content-id,一个Content-id是来在html里引用图片的,在使用MimeMessageHelper时候,spring帮你处理了这个过程后的很逻辑
抽象类:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ch15.SimplePicMail;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.mail.javamail.JavaMailSenderImpl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public abstract class AbstractMessageSender ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String to;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String from;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String subject;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected String text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected JavaMailSenderImpl sender;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getTo() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return to;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setTo(String to) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.to = to;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getFrom() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return from;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setFrom(String from) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.from = from;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getSubject() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return subject;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setSubject(String subject) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.subject = subject;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public String getText() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setText(String text) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.text = text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public JavaMailSenderImpl getSender() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return sender;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setSender(JavaMailSenderImpl sender) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.sender = sender;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
实现类:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ch15.SimplePicMail;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import javax.mail.MessagingException;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import javax.mail.internet.MimeMessage;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.core.io.FileSystemResource;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.mail.javamail.MimeMessageHelper;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class SimplePICMessageSender extends AbstractMessageSender ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private MimeMessageHelper helper;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private MimeMessage msg;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private FileSystemResource img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public FileSystemResource getImg() ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void setImg(FileSystemResource img) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.img = img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public void sendMessage()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
msg=sender.createMimeMessage();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
try ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper=new MimeMessageHelper(msg,true); //使用内嵌资源时,需要额外配置一个true参数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setTo(to);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setFrom(from);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setSubject(subject);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.setText(text,true);//true表示text/html格式邮件
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
helper.addInline("abc", img); //加入一个名为abc的内嵌资源
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(img);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
}catch (MessagingException e) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(e.getMessage());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sender.send(msg);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
配置文件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<?xml version="1.0" encoding="UTF-8"?>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<beans
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
xmlns="http://www.springframework.org/schema/beans"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean id="sender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="host">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>king.cn</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="username">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>gaoxiang</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="password">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>gaoxiang</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="javaMailProperties">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<props>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<prop key="mail.smtp.auth">true</prop>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<prop key="mail.smtp.timeout">10000</prop>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</props>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean id="messageSender" class="ch15.SimplePicMail.SimplePICMessageSender">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="sender">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<ref bean="sender"/>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="to">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>daryl715@tom.com</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="from">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>gaoxiang@king.cn</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="subject">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>html mime mail</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!-- 此处用cid:abc 表示实用的一个内嵌资源,名称为abc -->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="text">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value><![CDATA[<html><head><body>this is a pic mail<img src="cid:abc"></body></head></html>]]></value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<property name="img">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean class="org.springframework.core.io.FileSystemResource">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<bean class="java.io.File">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<value>./src/ch15/SimplePicMail/mail.jpg</value>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</constructor-arg>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</property>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</bean>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</beans>
测试代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
package ch15.SimplePicMail;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import java.io.File;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.context.ApplicationContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import org.springframework.context.support.ClassPathXmlApplicationContext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class SimplePICTest ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
public static void main(String[] args) throws Exception ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ApplicationContext context=new ClassPathXmlApplicationContext("ch15/SimplePicMail/applicationContext.xml");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SimplePICMessageSender mailSender=(SimplePICMessageSender)context.getBean("messageSender");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
for (int i = 0; i < 10; i++) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
mailSender.sendMessage();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println("成功");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Thread.sleep(2000); //发送后延时2秒钟
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
总体来说,最好避免使用内嵌图片,而使用url来访问图片,许多电子邮件客户端对内嵌图片支持有一定的问题,尤其是当他们组成像“复杂mime”时
相关文章推荐
- 《pro Spring》学习笔记之使用Spring+James邮件服务器发送带有附件的HTML邮件
- 《pro Spring》学习笔记之使用Spring+James邮件服务器发送普通HTML邮件
- 《pro Spring》学习笔记之使用Spring+James邮件服务器发送普通文本邮件
- 《pro Spring》学习笔记之使用Sprin+James邮件服务器发送可替换的HTML和纯文本邮件
- 《pro Spring》学习笔记之使用Velocity+Spring+James邮件服务器发送邮件
- 《pro Spring》学习笔记之使用Sprin+James邮件服务器发送复杂类型邮件
- VBS使用Jmail 发送带附件和图片的HTML邮件
- spring简单邮件发送(文本/html/图片/附件)
- 使用spring mail发送html邮件的示例代码
- Spring 发送邮件 内嵌图片增加附件
- 在windows平台使用Apache James搭建邮件服务器以及使用C#向外网发送邮件
- python应用系列教程——python使用smtp协议发送邮件:html文本邮件、图片邮件、文件附件邮件
- Spring 发送带有内嵌图片和附件的邮件的java程序
- Spring实现邮件发送之添加附件、内嵌图片
- javamail 发送邮件,发复杂html,包括附件,以及内嵌图片的邮件
- java实现发送邮件可多个附件内嵌图片-commons-email使用(未测试)
- java实现发送邮件可多个附件内嵌图片-commons-email使用
- 使用spring javamail smtp发送html邮件
- Spring 发送内嵌图片的邮件 遇到的问题
- 使用 Spring 的 JAVA Mail 发送 HTML 邮件