易截截图软件、单文件、免安装、纯绿色、仅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向Oracle数据库中插入大对象

通过JDBC,我们可以向oracle插入大对象,如图片,音频,长文本等,其插入方法有很多,这里演示一下通过流更新更新的形式插入CLOB大对象。
这是一个存储文本的例子,解释我会在程序中以注释的形式写出
/**
  * 将生成的表样存储到数据库
  *
  * @param htmlParam
  * @return
  */
  ......

Core Java Diaries

                                       线程
1---锁对象的方法----obj.wait()----obj.notify()----针对当前线程
& ......

JAVA中的位移操作 >> >>

中小
Java中共有三个移位操作符,分别是:
<<:左移操作,所有操作数向左移动,每移一位最右边用0补充
>>:带符号位右移:连同符号位一起右移,每移一位最左边用符号位补充
>>>:无符号右移:连同符号位一起右移,每移一位最左边用0补充
移位操作符只能作用于整数类型,即byte,short,char,i ......

java jar包打包命令

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

[JAVA] 深克隆 另外实现方法【序列化】

private static List cloneObject(
   Object obj) throws Exception {
  ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
  ObjectOutputStream out = new ObjectOutputStream(byteOut);
  out.writeObject(obj);
  ByteArrayInputStream byt ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号