Private voidButton1_Click (Objectsender, EventArgs e)//Click to get web Mail { if(TextBox1.Text.Trim ()! ="") {HttpWebRequest Wrst= (HttpWebRequest) webrequest.create (TextBox1.Text);//create a request for access to the Web content (source code) (text box 1 input URL)HttpWebResponse wrpse = (httpwebresponse) wrst. GetResponse ();//Feedback Web RequestStream s = wrpse. GetResponseStream ();//Stream feedback information into streamStreamReader sr =NewStreamReader (S, Encoding.default);//Store the contents of stream in Encoding.default encoded in the second flow SR stringx = Sr. ReadToEnd ();//define a variable x to receive Web page source code//MatchCollection applies the regular expression pattern to the set of successful matches found by the input string by replacing the constantMatchCollection MC = regex.matches (x,@"[a-za-z0-9_\-\.] [Email protected]\w+ (\.\w+) +");//The source code is stored in the Zone collection MC by the mailbox regular match .StringBuilder SB =NewStringBuilder ();//represents a mutable string foreach(Match minchOck//Start Traversal{sb. Appendline (m.value);//find a match and integrate (designators the found word into SB) append attach} TextBox2.Text=sb. ToString (); } Else{MessageBox.Show ("Please enter the correct URL"); } }
Save As
private void Save As ToolStripMenuItem _click (object sender, EventArgs e) { Savefiledialog1.filter = text file |*.txt ; DialogResult Dr = Savefiledialog1.showdialog (); if (Dr==dialogresult.ok) { string file = Savefiledialog1.filename; StreamWriter SW = new StreamWriter (f ILE); Sw. Write (TextBox2.Text); Sw. Close (); } }
Get the email in the Web page