国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
JavaMail - 發(fā)送HTML郵件
JavaMail - 發(fā)送HTML郵件

form.htm
========
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>郵件例程 - JavaMail - 發(fā)送HTML郵件</title>
</head>

<body>

<table border="0" cellspacing="0" cellpadding="0">
<form method="post" action="send.jsp">
<tr>
<td>SMTP主機:</td>
<td><input type="text" name="smtp" size="80"></td>
</tr>
<tr>
<td>發(fā)信人:</td>
<td><input type="text" name="from" size="80"></td>
</tr>
<tr>
<td>收信人:</td>
<td><input type="text" name="to" size="80"></td>
</tr>
<tr>
<td>抄送人:</td>
<td><input type="text" name="cc" size="80"></td>
</tr>
<tr>
<td>暗送人:</td>
<td><input type="text" name="bcc" size="80"></td>
</tr>
<tr>
<td>主題:</td>
<td><input type="text" name="subject" size="80"></td>
</tr>
<tr>
<td valign="top">內(nèi)容:</td>
<td><textarea name="body" rows="5" cols="80"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="發(fā)送"></td>
</tr>
</form>
</table>

</body>
</html>

send.jsp
========
<%--
作者:何志強[hhzqq@21cn.com]
日期:2000-08-16
版本:1.0
功能:郵件例程 - JavaMail - 發(fā)送HTML郵件
--%>

<%
//變量聲明
java.lang.String smtp,from,to,cc,bcc,subject,body;

//獲得用戶輸入數(shù)據(jù)
smtp = request.getParameter("smtp");
from = request.getParameter("from");
to = request.getParameter("to");
cc = request.getParameter("cc");
bcc = request.getParameter("bcc");
subject = request.getParameter("subject");
if(subject!=null){
subject = new java.lang.String(subject.getBytes("iso-8859-1"));
}
body = request.getParameter("body");

//發(fā)送郵件
pipi.mail.HTML.send(smtp,from,to,cc,bcc,subject,body);
%>

pipi.jaf.StringDataSource.java
==============================
/*
作者:何志強[hhzqq@21cn.com]
日期:2000-08-16
功能:字符串型數(shù)據(jù)源
*/

package pipi.jaf;

public class StringDataSource implements javax.activation.DataSource{
private java.lang.String data;
private java.lang.String type;

public StringDataSource(java.lang.String data,java.lang.String type){
this.data = data;
this.type = type;
}

public java.io.InputStream getInputStream() throws java.io.IOException{
return new java.io.StringBufferInputStream(data);
}

public java.io.OutputStream getOutputStream() throws java.io.IOException{
throw new java.io.IOException("it does not support this method now!");
}

public java.lang.String getContentType(){
return type;
}

public java.lang.String getName(){
return "pipi";
}
}

pipi.mail.HTML.java
===================
/*
作者:何志強[hhzqq@21cn.com]
日期:2000-08-16
功能:發(fā)送HTML郵件
*/

package pipi.mail;

public final class HTML{
public static void send(
java.lang.String smtp, /*SMTP主機地址*/
java.lang.String from, /*發(fā)信人*/
java.lang.String to, /*收信人*/
java.lang.String cc, /*抄送人*/
java.lang.String bcc, /*暗送人*/
java.lang.String subject, /*主題*/
java.lang.String body /*內(nèi)容*/
) throws java.lang.Exception{
//變量聲明
java.util.Properties props; //系統(tǒng)屬性
javax.mail.Session mailSession; //郵件會話對象
javax.mail.internet.MimeMessage mimeMsg; //MIME郵件對象

//設置系統(tǒng)屬性
props = java.lang.System.getProperties(); //獲得系統(tǒng)屬性對象
props.put("mail.smtp.host",smtp); //設置SMTP主機

//獲得郵件會話對象
mailSession = javax.mail.Session.getDefaultInstance(props,null);

//創(chuàng)建MIME郵件對象
mimeMsg = new javax.mail.internet.MimeMessage(mailSession);

//設置發(fā)信人
mimeMsg.setFrom(new javax.mail.internet.InternetAddress(from));

//設置收信人
if(to!=null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.TO,

javax.mail.internet.InternetAddress.parse(to));
}

//設置抄送人
if(cc!=null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.CC,

javax.mail.internet.InternetAddress.parse(cc));
}

//設置暗送人
if(bcc!=null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.BCC,

javax.mail.internet.InternetAddress.parse(bcc));
}

//設置郵件主題
//mimeMsg.setSubject(subject);
mimeMsg.setSubject(subject,"gb2312");

//設置郵件內(nèi)容
mimeMsg.setDataHandler(new javax.activation.DataHandler

(new pipi.jaf.StringDataSource(body,"text/html")));

//發(fā)送郵件
javax.mail.Transport.send(mimeMsg);
}
}

本套程序使用到JavaMail和JAVABEANS(TM) ACTIVATION FRAMEWORK(JAF):
  JavaMail
    http://java.sun.com/products/javamail/
  JAVABEANS(TM) ACTIVATION FRAMEWORK(JAF)
    http://java.sun.com/products/javabeans/glasgow/jaf.html



JavaMail - 發(fā)送HTML郵件

form.htm
========
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>郵件例程 - JavaMail - 發(fā)送HTML郵件</title>
</head>

<body>

<table border="0" cellspacing="0" cellpadding="0">
<form method="post" action="send.jsp">
<tr>
<td>SMTP主機:</td>
<td><input type="text" name="smtp" size="80"></td>
</tr>
<tr>
<td>發(fā)信人:</td>
<td><input type="text" name="from" size="80"></td>
</tr>
<tr>
<td>收信人:</td>
<td><input type="text" name="to" size="80"></td>
</tr>
<tr>
<td>抄送人:</td>
<td><input type="text" name="cc" size="80"></td>
</tr>
<tr>
<td>暗送人:</td>
<td><input type="text" name="bcc" size="80"></td>
</tr>
<tr>
<td>主題:</td>
<td><input type="text" name="subject" size="80"></td>
</tr>
<tr>
<td valign="top">內(nèi)容:</td>
<td><textarea name="body" rows="5" cols="80"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="發(fā)送"></td>
</tr>
</form>
</table>

</body>
</html>

send.jsp
========
<%--
作者:何志強[hhzqq@21cn.com]
日期:2000-08-16
版本:1.0
功能:郵件例程 - JavaMail - 發(fā)送HTML郵件
--%>

<%
//變量聲明
java.lang.String smtp,from,to,cc,bcc,subject,body;

//獲得用戶輸入數(shù)據(jù)
smtp = request.getParameter("smtp");
from = request.getParameter("from");
to = request.getParameter("to");
cc = request.getParameter("cc");
bcc = request.getParameter("bcc");
subject = request.getParameter("subject");
if(subject!=null){
subject = new java.lang.String(subject.getBytes("iso-8859-1"));
}
body = request.getParameter("body");

//發(fā)送郵件
pipi.mail.HTML.send(smtp,from,to,cc,bcc,subject,body);
%>

pipi.jaf.StringDataSource.java
==============================
/*
作者:何志強[hhzqq@21cn.com]
日期:2000-08-16
功能:字符串型數(shù)據(jù)源
*/

package pipi.jaf;

public class StringDataSource implements javax.activation.DataSource{
private java.lang.String data;
private java.lang.String type;

public StringDataSource(java.lang.String data,java.lang.String type){
this.data = data;
this.type = type;
}

public java.io.InputStream getInputStream() throws java.io.IOException{
return new java.io.StringBufferInputStream(data);
}

public java.io.OutputStream getOutputStream() throws java.io.IOException{
throw new java.io.IOException("it does not support this method now!");
}

public java.lang.String getContentType(){
return type;
}

public java.lang.String getName(){
return "pipi";
}
}

pipi.mail.HTML.java
===================
/*
作者:何志強[hhzqq@21cn.com]
日期:2000-08-16
功能:發(fā)送HTML郵件
*/

package pipi.mail;

public final class HTML{
public static void send(
java.lang.String smtp, /*SMTP主機地址*/
java.lang.String from, /*發(fā)信人*/
java.lang.String to, /*收信人*/
java.lang.String cc, /*抄送人*/
java.lang.String bcc, /*暗送人*/
java.lang.String subject, /*主題*/
java.lang.String body /*內(nèi)容*/
) throws java.lang.Exception{
//變量聲明
java.util.Properties props; //系統(tǒng)屬性
javax.mail.Session mailSession; //郵件會話對象
javax.mail.internet.MimeMessage mimeMsg; //MIME郵件對象

//設置系統(tǒng)屬性
props = java.lang.System.getProperties(); //獲得系統(tǒng)屬性對象
props.put("mail.smtp.host",smtp); //設置SMTP主機

//獲得郵件會話對象
mailSession = javax.mail.Session.getDefaultInstance(props,null);

//創(chuàng)建MIME郵件對象
mimeMsg = new javax.mail.internet.MimeMessage(mailSession);

//設置發(fā)信人
mimeMsg.setFrom(new javax.mail.internet.InternetAddress(from));

//設置收信人
if(to!=null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.TO,

javax.mail.internet.InternetAddress.parse(to));
}

//設置抄送人
if(cc!=null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.CC,

javax.mail.internet.InternetAddress.parse(cc));
}

//設置暗送人
if(bcc!=null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.BCC,

javax.mail.internet.InternetAddress.parse(bcc));
}

//設置郵件主題
//mimeMsg.setSubject(subject);
mimeMsg.setSubject(subject,"gb2312");

//設置郵件內(nèi)容
mimeMsg.setDataHandler(new javax.activation.DataHandler

(new pipi.jaf.StringDataSource(body,"text/html")));

//發(fā)送郵件
javax.mail.Transport.send(mimeMsg);
}
}

本套程序使用到JavaMail和JAVABEANS(TM) ACTIVATION FRAMEWORK(JAF):
  JavaMail
    http://java.sun.com/products/javamail/
  JAVABEANS(TM) ACTIVATION FRAMEWORK(JAF)
    http://java.sun.com/products/javabeans/glasgow/jaf.html

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
JSP與Java Mail API
Java發(fā)郵件 實現(xiàn)步驟+代碼
Java郵件發(fā)送程序
Java發(fā)郵件帶附件測試通過
JAVA MAIL發(fā)送郵件
javamail發(fā)信的
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服