Example:
Copy Code code as follows:
163.com of the mailbox in the early application is supported, the subsequent application is not supported.
21cn.com seems to have given up SMTP support now, and may only be paid by the user.
Qq.com's mailbox needs to be set in the user account.
I took a sina.com mailbox to test, also need in the backstage inside
Before you can send it. The detailed code is as follows:
Copy Code code as follows:
MailAddress from = new MailAddress ("sosuo8@sina.com");
MailAddress to = new MailAddress ("ahuinan@21cn.com");
MailMessage message = new MailMessage (from, to);
Message. Subject = "Letter from Ahanan";
Message. BODY = "Hello!" Test only ";
SmtpClient client = new SmtpClient ();
Client. Deliverymethod = Smtpdeliverymethod.network;
Client. Port = 25;
Client. Host = "smtp.sina.com";
Client. Credentials = new System.Net.NetworkCredential ("sosuo8@sina.com", "123");
Response.Write ("Send an email" + to.) User + "," + to. Host + "," + client. Host);
Client. Send (message);
Don't forget to introduce namespaces:
Copy Code code as follows:
Using System.Net;
Using System.Net.Mail;