C#smtp e-Mail

Source: Internet
Author: User
Tags mailmessage smtpclient

public static bool Sendmailuse ()
{
String host = "smtp.163.com";//mail server smtp.163.com means NetEase mailbox server
String userName = "[e-mail protected]";//Sender Account
string password = "a96606";//send-side password (password after this client is reset)

SmtpClient client = new SmtpClient ();
Client. Deliverymethod = smtpdeliverymethod.network;//Specify how e-mail is sent
Client. Host = host;//mail server
Client. useDefaultCredentials = true;
Client. Credentials = new System.Net.NetworkCredential (userName, password);//username, password

string strfrom = UserName;
String strto = "[email protected]";
String STRCC = "[email protected]";//CC


String subject = "Order title";//the subject of the message
String BODY = "Order title";//message body Sent

System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage ();
Msg. from = new MailAddress (Strfrom, "order");
Msg. To.add (Strto);
Msg. Cc. ADD (STRCC);

Msg. Subject = subject;//message Header
Msg. Body = body;//message content
Msg. bodyencoding = system.text.encoding.utf8;//message content encoding
Msg. isbodyhtml = true;//is an HTML message
Msg. Priority = mailpriority.high;//Message Precedence

Try
{
Client. Send (msg);
return true;
}
catch (System.Net.Mail.SmtpException ex)
{
return false;
}
}

C#smtp e-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.