package com.IFrame;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.event.ConnectionEvent;
import javax.mail.event.ConnectionListener;
import javax.mail.event.TransportEvent;
import javax.mail.event.TransportListener;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.swing.AbstractListModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JToolBar;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import com.dao.Dao;
import com.sun.mail.pop3.POP3Folder;
import com.util.ConvertPath;
import com.util.CreatecdIcon;
import com.wsy.Login;
public class InceptIFrame extends JInternalFrame implements ConnectionListener,TransportListener{
private JComboBox comboBox_3;
private JComboBox comboBox_2;
private JComboBox comboBox;
private JTextPane to_content;
private JTextField to_title;
private JTextField textField_2;
private JTextField to_mail;
JList jl=new JList();
private JPanel panel;
private String zi1,zi2,zi3;
DefaultListModel dl;
static File FilePath;
static List<File> l=new ArrayList<File>();
static String server=Login.getHost();
static String user=Login.getUsername().split("@")[0];
static String pass=Login.getPassword();
static String from=Login.getUsername();
Transport trans;
String body;
static boolean bold=false,italic=false, underline=false;
static Color Col=Color.black;
static int fontSize=12;
static String fontString="宋体";
POP3Folder folder;
public void messageDelivered(TransportEvent e) {
// TODO 自动生成方法存根
System.out.print(">>> TransportListener.messageDelivered().");
System.out.println(" Valid Addresses:");
Address[] valid = e.getValidSentAddresses();
if (valid != null) {
for (int i = 0; i < valid.length; i++)
System.out.println(" " + valid[i]);
}
}
public void messageNotDelivered(TransportEvent e) {
// TODO 自动生成方法存根
System.out.print(">>> TransportListener.messageNotDelivered().");
System.out.println(" Invalid Addresses:");
Address[] invalid = e.getInvalidAddresses();
if (invalid != null) {
for (int i = 0; i < invalid.length; i++)
System.out.println(" " + invalid[i]);
}
}
public void messagePartiallyDelivered(TransportEvent arg0) {
// TODO 自动生成方法存根
}
@Override
public Dimension minimumSize() {
// TODO 自动生成方法存根
return super.minimumSize();
}
public void opened(ConnectionEvent arg0) {
// TODO 自动生成方法存根
System.out.println(">>> ConnectionListener.opened()");
}
public void disconnected(ConnectionEvent arg0) {
// TODO 自动生成方法存根
}
public void closed(ConnectionEvent arg0) {
// TODO 自动生成方法存根
System.out.println(">>> ConnectionListener.closed()");
}
public InceptIFrame() {
super();
// TODO 自动生成构造函数存根
getContentPane().setLayout(null);
setIconifiable(true);
setTitle("新邮件");
setClosable(true);
setBounds(20, 0, 500, 414);
setVisible(true);
final JLabel label = new JLabel();
label.setText("收件人:");
label.setBounds(25, 70, 66, 18);
getContentPane().add(label);
final JLabel label_1 = new JLabel();
label_1.setText("抄送:");
label_1.setBounds(25, 100, 66, 18);
getContentPane().add(label_1);
to_mail = new JTextField();
to_mail.setToolTipText("将收件人地址以逗号分隔");
to_mail.setBounds(105, 65, 362, 22);
getContentPane().add(to_mail);
textField_2 = new JTextField();
textField_2.setBounds(105, 95, 362, 22);
getContentPane().add(textField_2);
final JLabel label_2 = new JLabel();
label_2.setText("主题:");
label_2.setBounds(25, 135, 66, 18);
getContentPane().add(label_2);
to_title = new JTextField();
to_title.setBounds(105, 130, 362, 22);
getContentPane().add(to_title);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(25, 200, 442, 170);
getContentPane().add(scrollPane);
to_content = new JTextPane();
scrollPane.setViewportView(to_content);
final JToolBar toolBar = new JToolBar();
toolBar.setBounds(0, 0, 490, 59);
getContentPane().add(toolBar);
final JButton button = new JButton();
button.setText("发送");
button.setIcon(CreatecdIcon.add("send.gif"));
toolBar.add(button);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成方法存根
try {
String to=to_mail.getText().trim();
String subject=to_title.getText().trim();
String body=to_content.getText().trim();
Properties props=new Properties();
props.setProperty("mail.transport.protocol", Login.getProtocol());
Session session=Session.getInstance(props);
session.setDebug(true);
String [] fromAddress;
StringBuffer sb=new StringBuffer();
if(dl.getSize()!=0){//带附件的邮件
for(int i=0;i<dl.getSize();i++){
try {
if(i==dl.getSize()-1){
sb.append(getFilePath().get(i).toString());
}
else{
sb.append(getFilePath().get(i).toString()+",");
}
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
else{
sb.append("无附件");
}
if(to.contains(",")){
fromAddress=to.split(",");
for(int i=0;i<fromAddress.length;i++){
sendMessage(session,fromAddress[i]);
Dao.InsertMailSend(subject, to, new Date().toLocaleString(), body, sb.toString(),"2",Login.getUsername());
}
}
else{
sendMessage(session,to);
Dao.InsertMailSend(subject, to, new Date().toLocaleString(), body, sb.toString(),"2",Login.getUsername());
}
JOptionPane.showMessageDialog(InceptIFrame.this, "邮件发送成功");
} catch (Exception e) {
// TODO 自动生成 catch 块
JOptionPane.showMessageDialog(InceptIFrame.this, "邮件发送失败"+e.getMessage());
e.printStackTrace();
}
//message.setRecipient(Mess, arg1)
}
});
final JButton button_1 = new JButton();
button_1.setText("重写");
button_1.setIcon(CreatecdIcon.add("rewrite.gif"));
button_1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成方法存根
if(to_content.getText().length()!=0){
to_content.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
运行程序,打开登录界面,如图1.6所示。填写POP3服务器地址、邮箱名称及密码,单击“登录”按钮,进入程序主界面。选择“邮件”/“新邮件”命令,打开邮件发送窗口,填写收件人地址、抄送、主题及内容,也可以插入附加,单击联系人名称,可将该联系人的邮箱地址添加到“收件人”文本框中,然后单击“发送”按钮,即可发送该邮件。邮件发送后,将保存到“已发送邮件”中。。。。
资源推荐
资源详情
资源评论
收起资源包目录
用Java和MySQL写的电子邮件系统 (173个子文件)
文档类别.bmp 1KB
文档类别.bmp 1KB
退出0.bmp 824B
退出0.bmp 824B
InceptIFrame.class 16KB
Dao.class 10KB
MainFrame.class 7KB
Deliver.class 6KB
Login.class 6KB
WriteProperties.class 5KB
DisplayMsg.class 4KB
Draft.class 4KB
MultipartViewer.class 4KB
AlreadySend.class 4KB
Draft$1.class 4KB
AddLinkMan.class 4KB
Deliver$1.class 3KB
InceptIFrame$1.class 3KB
InceptIFrame$3.class 3KB
AddLinkMan$2.class 3KB
HandleAttach.class 3KB
DisplayContent.class 3KB
AddLinkMan$5.class 2KB
MainFrame$1ClassNameTreeCellRenderer.class 2KB
Draft$1$3.class 2KB
MultipartViewer$1.class 2KB
Mail.class 2KB
Deliver$1$3.class 2KB
AlreadySend$1.class 2KB
Deliver$1$2.class 2KB
Draft$1$2.class 2KB
MainFrame$4.class 2KB
WriteProperties$1.class 2KB
InceptIFrame$9.class 2KB
InceptIFrame$MyCellRender.class 2KB
InceptIFrame$10.class 2KB
InceptIFrame$10$1.class 1KB
InceptIFrame$8.class 1KB
InceptIFrame$4.class 1KB
MainFrame$2.class 1KB
InceptIFrame$4$1.class 1KB
MainFrame$3.class 1KB
StringTrans.class 1KB
AlreadySend$TableTableModel.class 1KB
Draft$TableTableModel.class 1KB
ContentAction$AddLinkManAction.class 1KB
ContentAction$InceptAction.class 1KB
Deliver$TableTableModel.class 1KB
Login$1.class 1KB
Draft$2.class 1KB
MailAddress.class 1KB
AddLinkMan$1.class 1KB
AddLinkMan$6.class 1KB
Draft$1$1.class 1KB
InceptIFrame$5.class 1KB
InceptIFrame$7.class 1KB
InceptIFrame$6.class 1KB
Deliver$1$1.class 1KB
Terminator.class 1KB
ComponentFrame.class 983B
InceptIFrame$2.class 966B
LinkMan.class 959B
ContentAction.class 951B
Draft$ThisInternalFrameListener.class 932B
Login$2.class 925B
CreatecdIcon.class 884B
AddLinkMan$3.class 872B
AddLinkMan$4.class 790B
InceptIFrame$WordListModel.class 738B
MainFrame$1.class 685B
Deliver$2.class 635B
ConvertPath.class 568B
ReadFiles.class 533B
.classpath 485B
linkman.dat 186B
Thumbs.db 9KB
main.gif 121KB
main.gif 121KB
page.gif 2KB
page.gif 2KB
rewrite.gif 1KB
rewrite.gif 1KB
adjunct.gif 1KB
adjunct.gif 1KB
send.gif 1KB
send.gif 1KB
dui.gif 1KB
send3.gif 1KB
dui.gif 1KB
send3.gif 1KB
send1.gif 1005B
ip.gif 1005B
send1.gif 1005B
ip.gif 1005B
exit.gif 945B
exit.gif 945B
reader.gif 669B
reader.gif 669B
cuo.gif 644B
cuo.gif 644B
共 173 条
- 1
- 2
zuixinbingdu
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页