1. Get the authorization code for QQ mailbox
Open QQ Mailbox-Setup-account-Open POP3/SMTP service--Get authorization code based on operation
2. Set up and send mail--Method 1
(Two configuration methods)
-1: Configure Web. config, add the following code to the <configuration> tab
(AAAAAAAAAA: Indicates the mailbox number of your sender.)
BBBBBBBBBB: Represents the authorization code you obtained earlier.
Port number port: I test 25 can send, and 465 can't send (do not know why).)
<system.net> <mailSettings> <smtp deliverymethod= " network " from = " nekorz <[email protected]> " > <network host=" smtp.qq.com " username= " [email protected] " password=" BBBBBBBBBB " port=" 25 " /> </smtp> </mailsettings></ System.net>
-2: Add send mail code
(Nickname: Optional)
MailMessage mymessage =NewMailMessage (); Mymessage.subject="Test Message"; Mymessage.body="This is a test e-mail."; MYMESSAGE.TO.ADD (NewMailAddress ("[email protected]","Nickname")); SmtpClient mysmtpclient=NewSmtpClient (); Mysmtpclient.enablessl=true; Try{mysmtpclient.send (mymessage); } Catch(Smtpexception ex) {}
3. Set up and send mail--Method 2
(Only the configuration in Web. config is transferred to the code)
MailMessage mymessage =NewMailMessage (); Mymessage.subject="Test Message"; Mymessage.body="This is a test e-mail"; Mymessage.from=NewMailAddress ("[email protected]","Nickname"); MYMESSAGE.TO.ADD (NewMailAddress ("[email protected]","Nickname")); SmtpClient mysmtpclient=NewSmtpClient (); Mysmtpclient.host="smtp.qq.com"; Mysmtpclient.port= -; Mysmtpclient.credentials=NewSystem.Net.NetworkCredential ("[email protected]","bbbbbbbbbb"); Mysmtpclient.enablessl=true; Try{mysmtpclient.send (mymessage); } Catch(Smtpexception ex) {}
ASP.NET--QQ Mailbox Send mail