Use. net code to send emails, and. net code to send emails

Source: Internet
Author: User

Use. net code to send emails, and. net code to send emails

The example in this article shares the implementation code of. net mail for your reference. The specific content is as follows:

Key code:

Namespace to be referenced:

Using System. Net. Mail;
Using System. Net;

MailMessage mailObj = new MailMessage (); mailObj. from = new MailAddress ("mayun@qq.com"); // sender email address mailObj. to. add ("mahuateng@qq.com"); // recipient email address mailObj. subject = "Account Activation"; // topic mailObj. body = mailbody; // Body, mailObj. isBodyHtml = true; // indicates that the body content is HTML SmtpClient smtp = new SmtpClient (); smtp. host = "smtp.sina.cn"; // smtp server name smtp. useDefaultCredentials = true; smtp. credentials = new NetworkCredential ("mayun@qq.com", "pwd"); // sender's login name and password smtp. send (mailObj );

Note:

I,Smtp

SMTP (Simple Mail Transfer Protocol) is a set of rules for sending Mail from the source address to the destination address.

Make sure that this service is enabled in the email! Sina mail settings include:

2. "email names are not allowed. The server response is: Envolope sender mismatch with login user .. ".

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.