ASP.NET--QQ Mailbox Send mail

Source: Internet
Author: User
Tags mail code mailmessage smtpclient

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.