校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > 郵件發送簡單例子-bean文件

郵件發送簡單例子-bean文件

熱門標簽:廣州三五防封電銷卡 珠海銷售外呼系統運營商 四川電信外呼系統靠譜嗎 外呼系統啥意思 電銷外呼系統 排行榜 長春回撥外呼系統廠家 地圖標注制作道路 山東智能云外呼管理系統 地圖標注創業項目入駐
SimpleSendMessage.java

import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SimpleSendMessage {

public static void main(String[] args) {

// Collect the necessary information to send a simple message
// Make sure to replace the values for host, to, and from with
// valid information.
// host - must be a valid smtp server that you currently have
// access to.
// to - whoever is going to get your email
// from - whoever you want to be. Just remember that many smtp
// servers will validate the domain of the from address
// before allowing the mail to be sent.
String host = "server.myhost.com";
String to = "YourFriend@somewhere.com";
String from = "MeMeMe@myhost.com";
String subject = "JSP Rules!";
String messageText = "I am sending a message using the"
+ " JavaMail API.\nI can include any text that I want.";
boolean sessionDebug = false;

// Create some properties and get the default Session.
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");

Session session = Session.getDefaultInstance(props, null);

// Set debug on the Session so we can see what is going on
// Passing false will not echo debug info, and passing true
// will.
session.setDebug(sessionDebug);

try {

// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);

// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
}
catch (MessagingException mex) {

mex.printStackTrace();
}
}
}

標簽:肇慶 保定 廣元 紹興 北海 玉樹 吳忠 潮州

巨人網絡通訊聲明:本文標題《郵件發送簡單例子-bean文件》,本文關鍵詞  郵件,發送,簡單,例子,-bean,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《郵件發送簡單例子-bean文件》相關的同類信息!
  • 本頁收集關于郵件發送簡單例子-bean文件的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 客服| 沐川县| 平顶山市| 蓬莱市| 梨树县| 肥东县| 汽车| 西充县| 平原县| 乃东县| 扎囊县| 成都市| 珠海市| 正定县| 克拉玛依市| 抚州市| 沙田区| 浦东新区| 巩义市| 桐城市| 昔阳县| 新化县| 巍山| 定西市| 壶关县| 房山区| 汕头市| 宜黄县| 营口市| 余干县| 鄱阳县| 栖霞市| 广灵县| 通渭县| 凤翔县| 罗定市| 乐安县| 伊川县| 天津市| 酉阳| 永定县|