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.