How to send email in Applet
Tianjin University Electronic Department Fanzhong
To get feedback, I will be embedded on the home page when designing the home page. Reader to connect with us. The most common practice is to use HTML language plus: feedback to author! This is the disadvantage of this is whether the reader is using Internet Explorer or Netscape Navigator, you need to open a writing window in the case of clicking the author address, so that the home window is overwritten . This reader does not easily take it in this reader. The author sets a Java applet on the home page to solve this problem, which makes people who do not have the Email address can also feed.
The source program is as follows: import java.awt. *; Import java.applet. *; Import java.net. *; Import java.io. *; Public class javamail extends applet {private int smtp_port = 25; // mail server default port number private String appletSource = "202.99.96.140"; // author mail server IPprivate TextArea MsgArea; private TextField senderField, recipientField, hostField; public void init () {setLayout (new BorderLayout ()); Panel fields = new Panel () Fields.setLayout (New GridLayout (3, 1)); Panel recpanel = new panel (); recpanel.setLayout (New GridLayout (2, 1)); recpanel.add (New Label ("Recipient)); RecipientField = New TextField ("zffan"); // Author's mail server User name RECPANEL.ADD (RecipientField); Fields.Add (RecPanel); Panel sendpanel = new panel (); sendpanel.setLayout (New GridLayout (2, 1)); SendPanel.Add (New Label ("Sender")); senderfield = new textfield ("Your name"); // fill in the user name Sendpanel.Add (Senderfield); Fields.Add (Sendpanel); Panel Hostpanel = New HostPanel.setLayout (New GridLayout (2, 1)); HostPanel.Add (New Label ("Host")); hostfield = New TextField ("Yourcompany. COM "); // Fill in the reader's mail server iphostpanel.add (Hostfield); add (" north ", fields); msgarea = new textarea (); add (" center ", msgarea) Add ("South", New Button ("Send"));} public boolean handleevent (EVENT E) {if (E.ID == Event.Window_Destroy) System.exit (0); Return Super.HandleEvent (E) } public boolean action {if (arg.equals ("send")) Sendmsg (Senderfield.getText (), Recipientfield.getText (), hostfield.getText (); Elsereturn Super.Action e, arg); Return True;} private video