mailSendFrame.java源程序代码如下:
import java.awt.*; import java.awt.event.*; public class mailSendFrame extends Frame { smtpMail mailSender=new smtpMail(); Panel panelMain = new Panel(); Panel panelUp = new Panel(); Panel panel3 = new Panel(); Panel panel4 = new Panel(); Panel panel6 = new Panel(); Panel panel7 = new Panel(); TextField txtServer = new TextField(); TextField txtTo = new TextField(); TextField txtFrom = new TextField(); TextField txtSubject = new TextField(); Panel panel8 = new Panel(); Label lblFile = new Label(); Button cmdBrowse = new Button(); Panel panelDown = new Panel(); TextArea txtMail = new TextArea(); Panel panel10 = new Panel(); Button cmdSend = new Button(); Button cmdExit = new Button(); private FileDialog openFileDialog = new FileDialog(this,"打开文件",FileDialog.LOAD); public mailSendFrame() { try { Init(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { mailSendFrame mailSendFrame = new mailSendFrame(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = mailSendFrame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } mailSendFrame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); mailSendFrame.setVisible(true); mailSendFrame.show(); } private void Init() throws Exception { this.setLayout(new BorderLayout()); panelMain.setLayout(new GridLayout(2,1)); panelUp.setLayout(new GridLayout(6,1)); panel3.setLayout(new FlowLayout()); this.setVisible(true); ....... ....... //smtpMail.java 的源代码 import java.io.*; import java.net.Socket; import java.util.*; public class smtpMail{ private boolean sendConf=false; public static final int OK = 1; public static final int ERROR = 0; private static final String TEXT = "1"; private static final String TFILE = "2"; private static final String BFILE = "3"; private static final String CPR = "Java 1.0"; private static final String MAILER = "X-Mailer"; private static final int BUFFER_SIZE = 48; private String DELIMETER; private String SEPARATOR; private static final int HOW_LONG = 6; private static final char SMTP_ERROR_CODE1 = 52; private static final char SMTP_ERROR_CODE2 = 53; private static final int fillchar = 61; private static final String cvt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; private Socket mailSocket; private BufferedReader recv; private PrintWriter send; private String from; private String to; private String domain; private Vector x_set; private Vector body; private Vector attach; public smtpMail(){ DELIMETER = ""; SEPARATOR = ""; mailSocket = null; recv = null; send = null; from = ""; to = ""; domain = ""; x_set = new Vector(); body = new Vector(); attach = new Vector(); DELIMETER = getId(); SEPARATOR = System.getProperty("file.separator"); } ......... ......... |
|
|