易截截图软件、单文件、免安装、纯绿色、仅160KB

smtp of java mail

send mail use smtp .u can send text or html, send to many peoples if u have a email user and pwd and the smtp of the email which u use.
package org.lc.smtp;
import java.io.IOException;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.util.ByteArrayDataSource;
import com.sun.mail.smtp.SMTPTransport;
/**
* smtp send mail.
* @author lc.
*/
public class smtp {
Message message;
Properties properties = new Properties();
Session session;
/**
*
* @param from mail from
* @param pwd mail pwd
* @param host mail from smtp host
* @param to to someone's mail
*/
public smtp(String from, String pwd, String host, String to) throws MessagingException, IOException {
properties.put("mail.smtp.host", host);// set smtp properties
session = Session.getInstance(properties);
message = new MimeMessage(session);
message.setSubject("title of mail");// set titile
message.setText("text");//send text
message.setDataHandler(new DataHandler(new ByteArrayDataSource("<a href="\" mce_href="\""http://www.baidu.com\">ahaha..</a>".toString(), "text/html")));// send html
message.setfrom(new InternetAddress(from));// set send from
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to,false));// set send where

SMTPTransport t = (SMTPTransport) session.getTransport("smtp");
t.connect(host, from, pwd);
t.sendMessage(message, message.getAllRecipients());
}

public static void main(String[] args) throws Exception {
new smtp(args[0], args[1], args[2], args[3]);
}

}


相关文档:

java 数据存储器

        前些天和一个C++程序员聊天时,聊到一些对象、数组存储空间时,由于两人都不是大鸟,之前也看过一些java存储数据的资料,但都是过目便忘。也没有进行总结过。下面是转载过来,感觉总结的很全面。
       java对象内存机制:http://java.chinait ......

java开发中Mysql中文乱码问题的解决

     Mysql在默认情况下建立表的字符编码是latin1,所以在插入中文时会出错。
eg:
1、查看表建立的sql源码:
1: sql命令:show create table users
2:
3: 结果:
4: CREATE TABLE `users` (
5: `userID` int(10) unsigned NOT NULL AUTO_INCREMENT,
6: `userName` varchar(4 ......

java jar包打包命令

jar -cvf  name.jar *.*(打包此目录下所有文件)
jar -cvf  name.jar  filename(打包此目录下单个文件helloWorld.java或文件夹)
jar -cvf name.jar filename1  filename2....(打包此目录下多个文件或文件夹)
参考: jar ......

Java服务器端List对象转换为JSON对象并返回客户端实例


一、什么是JSON
  JSON 即 JavaScript Object Natation(Java对象表示法),它是一种轻量级的数据交换格式,非常适合于服务器与 JavaScript 的交互。
  简而言之,JSON就是JavaScript交换数据的一种格式。例子如下:
{"username":"coolcooldool","password":"1230","usertype":"superadmin"}
{"list":[{"password": ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号