In the past two days, you need to create a webpage that collects information submitted by users and then sends an email to the specified email address. You can use the class below system. net. Mail to send emails in Asp.net 2.0. The http://www.systemnetmail.com/faq/2.1.aspx address is written by the author of system. net. Mail as if it is similar to msdn FAQ, seeCodeYou can refer to the following. Don't talk about anything. paste the code below. After all, the Code is the most important:
1 Protected Void Btnsend_click ( Object Sender, eventargs E)
2 {
3 Mailmessage = New Mailmessage ();
4 String Strbody;
5
6 Mailmessage. From = New Mailaddress ( " 365rss@gmail.com " );
7 Mailmessage. to. Add ( " Prlibertine@gmail.com " );
8 Mailmessage. Subject = " 365rss. cn " ;
9
10 Strbody = " <H2> " + Ddlmaintag. selecteditem. Text + " </H2> <br> " ;
11 Strbody + = " <H4> " + Tbtag. Text + " </H4> <br> <HR> <br> " ;
12 Strbody + = " · " + Tbadv. text;
13
14 Sendmail (mailmessage );
15 }
16
17 // Sendmail
18 Private Void Sendmail (mailmessage Mail)
19 {
20 Smtpclient = New Smtpclient ();
21 Smtpclient. enablessl = True ;
22 Smtpclient. Host = " Smtp.gmail.com " ;
23 Smtpclient. Port = 465 ;
24 Smtpclient. Credentials = New Networkcredential ( " 365rss@gmail.com " , " PWD " );
25 Try
26 {
27Smtpclient. Send (Mail );
28Label1.text= "OK";
29}
30 Catch
31 {
32Label1.text= "False";
33}
34 }
35