资源描述:
《2012邮件发送》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、邮件发送方法名作用setHostName(StringaHostName)使用aHostName作为发送邮件的服务器addTo(Stringemail)设置收件人邮箱setFrom(Stringemail)设置发件人邮箱setAuthentication(Stringusername,Stringpassword)发件人邮箱在邮件服务器上的账号和密码setSubject(StringaSubject)设置邮件的主题setMsg(Stringmsg)设置邮件的内容send()发送邮件packagecom.java2010
2、.em;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPasswordField;importjavax.swing.JScrollPane;importjavax.swing.JT
3、extArea;importjavax.swing.JTextField;importorg.apache.commons.mail.SimpleEmail;publicclassEmextendsJFrame{//7个标签JLabeljl1,jl2,jl3,jl4,jl5,jl6,jl7;//5个文本框JTextFieldjtf1,jtf2,jtf3,jtf4,jtf5;//1个密码框JPasswordFieldjpf;//1个文本域JTextAreajta;//滚动条JScrollPanejsp;//按钮JButt
4、onjb1;publicEm(){jl1=newJLabel("邮箱服务器地址:");jl1.setBounds(20,20,160,25);jtf1=newJTextField();jtf1.setBounds(120,20,200,25);jl2=newJLabel("收件人邮箱:");jl2.setBounds(20,60,160,25);jtf2=newJTextField();jtf2.setBounds(120,60,200,25);jl3=newJLabel("发送人邮箱:");jl3.setBounds
5、(20,100,160,25);jtf3=newJTextField();jtf3.setBounds(120,100,200,25);jl4=newJLabel("用户姓名:");jl4.setBounds(20,140,80,25);jtf4=newJTextField();jtf4.setBounds(80,140,80,25);jl5=newJLabel("用户密码:");jl5.setBounds(180,140,80,25);jpf=newJPasswordField();jpf.setBounds(240
6、,140,80,25);jl6=newJLabel("邮件标题:");jl6.setBounds(20,180,160,25);jtf5=newJTextField();jtf5.setBounds(120,180,200,25);jl7=newJLabel("内容:");jl7.setBounds(20,220,80,25);jta=newJTextArea();jsp=newJScrollPane(jta);jsp.setBounds(20,260,300,120);jb1=newJButton("邮件发送");j
7、b1.addActionListener(newActionListener(){@OverridepublicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstubdo_but(e);}});jb1.setBounds(120,400,120,30);this.add(jl1);this.add(jtf1);this.add(jl2);this.add(jtf2);this.add(jl3);this.add(jtf3);this.add(jl
8、4);this.add(jtf4);this.add(jl5);this.add(jpf);this.add(jl6);this.add(jtf5);this.add(jl7);this.add(jsp);this.add(jb1);this.setLayout(null);//标题this.setTitle("力天邮件发送");