?? 0184.htm
字號(hào):
<html>
<head>
<title>新時(shí)代軟件教程:操作系統(tǒng) 主頁(yè)制作 服務(wù)器 設(shè)計(jì)軟件 網(wǎng)絡(luò)技術(shù) 編程語(yǔ)言 文字編輯</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋體}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1 {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>郵件發(fā)送簡(jiǎn)單例子-bean文件</strong></big></p>
<div align="right">---摘自互聯(lián)網(wǎng)</div>
<br>SimpleSendMessage.java<br>
<br>
import java.util.*;<br>
<br>
import javax.mail.*;<br>
import javax.mail.internet.*;<br>
import javax.activation.*;<br>
<br>
public class SimpleSendMessage {<br>
<br>
public static void main(String[] args) {<br>
<br>
// Collect the necessary information to send a simple message<br>
// Make sure to replace the values for host, to, and from with<br>
// valid information.<br>
// host - must be a valid smtp server that you currently have<br>
// access to.<br>
// to - whoever is going to get your email<br>
// from - whoever you want to be. Just remember that many smtp<br>
// servers will validate the domain of the from address<br>
// before allowing the mail to be sent.<br>
String host = "server.myhost.com";<br>
String to = "YourFriend@somewhere.com";<br>
String from = "MeMeMe@myhost.com";<br>
String subject = "JSP Rules!";<br>
String messageText = "I am sending a message using the"<br>
+ " JavaMail API.\nI can include any text that I want.";<br>
boolean sessionDebug = false;<br>
<br>
// Create some properties and get the default Session.<br>
Properties props = System.getProperties();<br>
props.put("mail.host", host);<br>
props.put("mail.transport.protocol", "smtp");<br>
<br>
Session session = Session.getDefaultInstance(props, null);<br>
<br>
// Set debug on the Session so we can see what is going on<br>
// Passing false will not echo debug info, and passing true<br>
// will.<br>
session.setDebug(sessionDebug);<br>
<br>
try {<br>
<br>
// Instantiate a new MimeMessage and fill it with the<br>
// required information.<br>
Message msg = new MimeMessage(session);<br>
<br>
msg.setFrom(new InternetAddress(from));<br>
InternetAddress[] address = {new InternetAddress(to)};<br>
msg.setRecipients(Message.RecipientType.TO, address);<br>
msg.setSubject(subject);<br>
msg.setSentDate(new Date());<br>
msg.setText(messageText);<br>
<br>
// Hand the message to the default transport service<br>
// for delivery.<br>
Transport.send(msg);<br>
}<br>
catch (MessagingException mex) {<br>
<br>
mex.printStackTrace();<br>
}<br>
}<br>
}
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -