SmtpClient class, SmtpClient
SmtpClient class
Allow applications to send emails using Simple Mail Transfer Protocol (SMTP.
Namespace: System.net. mail
Attribute
ClientCertificates: Specifies the certificate to use to establish a Secure Socket Layer (
The mail sending function is used in a recent project. This is different from the method used to send emails for a previous project. Previously, information about the emails to be sent was inserted into a database table on the server. The database
Today, I sent a mail to the mailbox smtpclient. The MailServer on the shelf is normal, but the MailServer on the other side is lost. It is found that the mailbox certificate appears, but the Outlook mail is normal, if no result is found, use the
Objective There are many ways to send mail, such as sending mail via the. Net Framework's built-in SmtpClient, using an open source project Lumisoft.net, and so on, and here's how to use SmtpClient under the System.Net.Mail namespace to send mail.
In the previous mailmessage saved as an EML file (C # + smtpclient), we used the Reflection Method to call system. net. mailwriter, the internal object of mail, implements saving mailmessage content as an EML file.
Through the previous
ASP. NET series: SmtpClient and asp. netsmtpclient for unit testing
When SmtpClient is used to send an Email, we can create an ISmtpClient interface and a SmtpClientWrapper adaptation class. In the unit test, we can perform Mock or custom
. Net has greatly improved the mail. smtpclient function since 2.0. It is easy to send emails. However, the US lacks the ability to save the email content as an EML file.
In fact, smtpclient and mailmessage have implemented this function, but this
For the first time, I used this method to send an email. For example, I used my live mailbox to send an email to my QQ mailbox.
The steps for sending an email using smtpclient will not be discussed. You can find too many information on the Internet.
ProgramYes:
CopyCode The Code is as follows: static void main (string [] ARGs)
{
Smtpclient client = new smtpclient ();
Client. Host = "localhost ";
Mailaddress from = new mailaddress ("from@test.com ");Mailaddress to = new mailaddress ("to@
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.