C # send a simple email,

Source: Internet
Author: User
Tags mailmessage smtpclient

C # send a simple email,

System. Net. Mail. MailMessage message = new System. Net. Mail. MailMessage ();
Message. From = new System. Net. Mail. MailAddress ("***** @ 163.com"); // send email
Message. To. Add ("********* @ qq.com"); // recipient
Message. Subject = "**********"; // mail title
Message. IsBodyHtml = true;
Message. BodyEncoding = System. Text. Encoding. UTF8;
Message. Body = "***************"; // mail content
Message. Priority = System. Net. Mail. MailPriority. Normal;
System. Net. Mail. SmtpClient client = new System. Net. Mail. SmtpClient ("smtp.163.com", 25); // 163 email address, 25 port number
Client. credentials = new System. net. networkCredential ("*********** @ 163.com"," ********* "); // The Mail Box Name of the first parameter, the second parameter mailbox Password
Client. EnableSsl = false; // ssl encryption is required.
Try
{
Client. Send (message); // Send
}
Catch (Exception ee)
{
LogHelper. GetInstance (). WriteMessage (DateTime. Now + "failed to send the order Email:" + ee. Message); // failed to send, Operation
}

 

This message only tests personal accounts and does not test enterprise-level mailboxes. If you have any questions at the enterprise level, you can communicate with each other.

 

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.