java cut image and send html email....

Image croppedImage = null;
ImageFilter cropFilter = new CropImageFilter(left, top, 110, 150); // 截取局部图像
ImageProducer producer = new FilteredImageSource(srcImage
.getSource(), cropFilter);
croppedImage = Toolkit.getDefaultToolkit().createImage(producer);
// System.out.println("截取后的长宽为:" + croppedImage.getWidth(null)
// + "\tcopsh==" + croppedImage.getHeight(null));

// int wideth=inputImage.getWidth(null); //得到源图宽
// int height=inputImage.getHeight(null); //得到源图长
BufferedImage tag = new BufferedImage(110, 150,
BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(croppedImage, 0, 0, 110, 150, null); // 可缩放图像
FileOutputStream out = new FileOutputStream(saveFile); // 输出到文件流
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag); // 近JPEG编码
out.close();
in.close();



-------------------java send html email


applicationContext.xml

--
<bean id="sender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
<value>smtp.163.com</value>
</property>
<property name="username">
<value>snwfn25</value>
</property>
<property name="password">
<value>******</value>
</property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>


--注入到业务逻辑去
org.springframework.mail.javamail.JavaMailSenderImpl sender


/** 发外部电子邮件 */
MimeMessage msg = this.sender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(msg, true,
"GB2312");
helper.setTo(login.getEmail());
helper.setFrom("[email protected]");
helper.setSubject("欢迎您加入模特星缘工作交友网");
helper.setText(email.toString(), true);
try {

this.sender.send(msg);
} catch (Exception ex) {
                                                            ex.printStackTrace();
}



你可能感兴趣的:(java,html,xml,工作)