快速业务通道

用APPLET发送E-MAIL的源代码 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-20
ayout); this.setLayout(panelLayout1); thsi.add(panel1,new PaneConstraints("panel1","panel1",PaneConstraints.ROOT,1.0f)); panel1.add(label1,new XYConstraints(10,5,80,20)); panel1.add(label2,new XYConstraints(10,30,80,20)); panel1.add(textField1,new XYConstraints(95,5,200,20)); panel1.add(textField2,new XYConstraints(95,30,200,20)); panel1.add(label3,new XYConstraints(10,60,80,20)); panel1.add(textArea1,new XYConstraints(10,80,300,150)); panel1.add(button1,new XYConstraints(50,240,80,25)); panel1.add(button2,new XYConstraints(160,240,80,25)); textField1.setText(get); textField2.setText(send); }//end of jbInit() public String getAppletInfo(){ return "Applet Information";} public String[][] getParameteInfo(){ return null;} void sendMail(){ String sender=textField2.getText(); String geter=textField1.getText(); String memo=textArea1.getText(); StringTokenizer st=new StringTokenizer(sender,"@"); int count=st.countTokens(); if(count!=2){ MessageDialog mdlg=new MessageDialog(frame,"邮件地址错误","你的发信人地址错误,请确认后重新发送!!",1); mdlg.show(); textField2.selectAll(); return;} String senderName=st.nextToken(); String senderHost=st.nextToken(); st=new StringTokenizer(geter,"@"); count=st.countTokens(); if(count!=2){ MessageDialog mdlg=new MessageDialog(frame,"邮件地址错误","你的收信人地址错误,请确认后重新发送!!",1); mdlg.show(); textField1.selectAll(); return;} String geterName=st.nextToken(); String geterHost=st.nextToken(); try{ Socket s=new Socket(geterHost,SMTP_PORT); PrintStream out=new PrintStream(s.getOutputStream()); out.println("HELLO:"+senderHost); /*邮件服务器不认证读者所输SMTP是否正确*/ out.println("MAIL FORM:"+senderName); out.println("RCPT TO:"+geterName); out.println("DATA"); out.println(memo); out.println(".\nQUIT"); MessageDialog mdlg=new MessageDialog(frame,"邮件地址正确","恭喜,您的邮件已经成功发送",1); mdlg.show();} catch(Exception e){ System.out.println(e.toString()); MessageDialog mdlg=new MessageDialog(frame,"邮件发送失败",e.toString(),1);//"邮件发送出错,请确认合重新发送!",1); mdlg.show(); return;} }//end of sendMail() void button1_actionPerformed(ActionEvent e){ sendMail(); textArea1.setText("");} void button2_actionPerformed(ActionEvent e){ textField1.setText(""); textFIeld2.setText(""); textArea1.setText("");} }//end of MailApplet class MailApplet_button1_actionAdapter implements java.awt.event.ActionListener{ MailApplet adaptee; MailApplet_button1_actionAdapter(MailApplet adaptee){ this.adaptee=adaptee;} public void actionPerformed(ActionEvent e){ adaptee.button1_actionPerformed(e);} }//end of this class MailApplet_button2_actionAdapter implements java.awt.event.ActionListener{ MailApplet adaptee; MailApplet_button2_actionAdapter(MailApplet adaptee){ this.adaptee=adaptee;} public void actionPerformed(Act

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号