| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 864 人关注过本帖
标题:[求助]程序出错,高手救急呀!!!
取消只看楼主 加入收藏
tank1128911
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-11-2
收藏
 问题点数:0 回复次数:0 
[求助]程序出错,高手救急呀!!!

下面是俺正在调试的程序,但老出错。请高手们帮忙看一下,小弟感激不尽!!

import javax.mail.*; import javax.mail.internet.*; import java.util.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.io.*;

class SendMail implements ActionListener { public void actionPerformed(ActionEvent evt) { try { Properties props = new Properties(); props.put("mail.host",hostField.getText()); Session mailConnection = Session.getInstance(props,null); final Message msg = new MineMessage(mailConnection); Address to = new InternetAddress(toField.getText()); Address from= new InternetAddress(fromField.getText()); msg.setContent(message.getText(),"text/plain"); msg.setForm(from); msg.setRecipient(Message.RecipientType.TO,to); msg.setSubject(subjectField.getText());

Runnable r = new Runnable() { public void run() { try { Transport.send(msg); } catch (Exception e) { e.printStackTrance(); } } }; Thread t = new Thread(r); t.start();

message.setText(""); } catch (Exception e) { e.printStackTrace(); } } }

public class useSMTPMail extends JFrame { private JButton sendButton = new JButton("Send Message"); private JLabel fromLabel = new JLabel("From:"); private JLabel toLabel = new JLabel("T"); private JLabel hostLabel = new JLabel("SMTP Server:"); private JLabel subjectLabel = new JLabel("Subject:"); private JTextField fromField = new JTextField(40); private JTextField toField = new JTextField(40); private JTextField hostField = new JTextField(40); private JTextArea message = new JTextArea(40,72); private JScrollPane jsp = new JScrollPane(message);

public useSMTPMail() { super("SMTP Client"); Container contentPane = this.getContentPane(); contentPane.setLayout(new BorderLayout());

JPanel labels = new JPanel(); labels.setLayout(new GridLayout(4,1)); labels.add(hostLabel);

JPanel fields = new JPanel(); fields.setLayout(new GridLayout(4,1)); String host = System.getProperty("mail.host",""); hostField.setText(host); fields.add(hostField); labels.add(toLabel); fields.add(toField);

String form = System.getProperty("mail.from",""); fromField.setText(from); labels.add(fromLabel); fields.add(fromField); labels.add(subjectLabel); fields.add(subjectField); Box north = Box.createHorizontalBox(); north.add(labels); north.add(fields); contentPane.add(north,BorderLayout.NORTH); message.setFont(new Font("Monospaced",Font.PLAIN,12)); contentPane.add(jsp,BorderLayout.CENTER); JPanel sonth = new JPanel(); south.setLayout(new FlowLayout(FlowLayout.CENTER)); south.add(sendButton); sendButton.addActionListener(new SendMail()); contentPane.add(south,BorderLayout.SOUTH); this.pack(); } public static void main(String[] args) {useSMTPMail smail = new useSMTPMail(); smail.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); smail.show(); } }

搜索更多相关主题的帖子: public import null 
2004-11-03 18:39
快速回复:[求助]程序出错,高手救急呀!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044656 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved