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]);
}
}
相关文档:
通过JDBC,我们可以向oracle插入大对象,如图片,音频,长文本等,其插入方法有很多,这里演示一下通过流更新更新的形式插入CLOB大对象。
这是一个存储文本的例子,解释我会在程序中以注释的形式写出
/**
* 将生成的表样存储到数据库
*
* @param htmlParam
* @return
*/
  ......
线程
1---锁对象的方法----obj.wait()----obj.notify()----针对当前线程
& ......
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虚拟机启动时,关于类加载方面的一些动作
当使用java ProgramName.class运行程序时,Java找到JRE,接着找到jvm.dll,把该动态库载入内存,这就是JVM。然后加载其它动态库, 并激活JVM。JVM激活之后会进行一些初始化工作,之后生成BootstrapLoader,该Class Loader是由C++写的。BootstrapLoader加载Launche ......
好久没用java,突一写起来,发现机器上没有设置环境变量,把设置方法总结一下
1. 修改/etc/profile文件
如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性问题。
·用文本编辑器打开/etc/profile
·在pr ......