asp.net System.Net.Mail Send mail _ Practical tips

Source: Internet
Author: User
Tags mailmessage smtpclient
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;
Related Article

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.