protected void Button1_Click (object sender, EventArgs e) {sendsmtpemail ("smtp.qq.com", "[email& Nbsp;protected] "," XX password xxxx "," [email protected] "," 123 "," Send mail with ASP, use QQ smtp.qq.com server, Test Success "); public void Sendsmtpemail (string strsmtpserver, String strfrom, String Strfrompass, String strto, String strsub Ject, String strbody) {System.Net.Mail.SmtpClient client = new SmtpClient (strsmtpserver); Client. useDefaultCredentials = false; Client. Credentials = new System.Net.NetworkCredential (strfrom, Strfrompass); Client. Deliverymethod = Smtpdeliverymethod.network; System.Net.Mail.MailMessage message = new MailMessage (strfrom, Strto, Strsubject, strbody); Message. bodyencoding = System.Text.Encoding.UTF8; Message. Isbodyhtml = true; Client. Send (message); }//The first parameter is a mailbox server//second parameter sender's account//third parameter sender password//fourth parameter recipient account The fifth parameter topic//sixth parameter content.
Note: If QQ Mail sender's QQ mailbox must be set as follows, and the recipient's mailbox does not have to be set.
1.
2.
3.
Here's a more detailed introduction:
public void Sendmailusezj () {System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage (); Msg. To.add ("[email protected]"); Msg. To.add ("Fill in the address here such as [email protected]"); Msg. To.add ("[email protected]"); Can be sent to multiple people//msg. Cc. Add ("[email protected]"); Can be copied to many people msg. from = new MailAddress ("[email protected]", "SFADSXCVXXV", System.Text.Encoding.UTF8);/* The above 3 parameters are the sender address (can be written casually), Sender name, encoding */MSG. Subject = "AAAAA";//message header MSG. subjectencoding = system.text.encoding.utf8;//message header encoded MSG. Body = "adsssssssss";//message content Msg. bodyencoding = system.text.encoding.utf8;//message content encoded MSG. Isbodyhtml whether =true;//is an HTML mail//msg. Priority = mailpriority.high;//message SmtpClient client = new SmtpClient (); Client. Credentials = new System.Net.NetworkCredential ("[email protected]", "77777777"); e-mail account password sent. This must be written about yourself, I use the 126 client. Host = "SMTP."126.com "; Object userState = msg; try {//client. SendAsync (msg, userState); Client. Send (msg); Label1.Text = "sent successfully!!" "; } catch (System.Net.Mail.SmtpException ex) {Label1.Text = "send failed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; /Front desk label, needless to say}}
Incidental points:
The server address is: QQ mailbox
pop3:pop.qq.com;
Smtp:smtp.qq.com 163 Email
Pop3:pop.163.com
Smtp:smtp.163.com
The address of the Sina Free mailbox (SMTP) server is: smtp.sina.com
Sina free email inbox (POP3) the address of the server is: pop.sina.com
Other on the Internet to find it.
ASP. NET Send mail