Asp. Net Mail Send System.Net.Mail case _ practical Tips

Source: Internet
Author: User
Tags mailmessage smtpclient

This example for you to share the ASP.net mail sent cases for your reference, the specific content as follows

1. Front Page sendemail.aspx Code

 

2, background SendEmail.aspx.cs code

protected void Btn_sendemail_click (object sender, EventArgs e) {//Declare a Mail object mailmessage mymail = new MailMessage (); Sender address//As yourself, enter your own mailbox MyMail here.
 from = new MailAddress ("15510180880@163.com"); Recipient address MyMail.
 To.add (New MailAddress (Tb_email.text)); Message subject mymail.
 Subject = Tb_subject.text; The message header is encoded mymail.
 subjectencoding = System.Text.Encoding.UTF8; The content of the send message mymail.
 BODY = Tb_body.text; The message content is encoded mymail.
 bodyencoding = System.Text.Encoding.UTF8;
 Add Attachment Attachment myfiles = new Attachment (tb_Attachment.PostedFile.FileName); MyMail.
 Attachments.Add (myfiles); CC to other mailbox MyMail. Cc. ADD (New MailAddress (TB_CC).
 Text)); Whether it is an HTML mail mymail.
 Isbodyhtml = true; Message priority MyMail.
 Priority = Mailpriority.high;
 Create a mail server class SmtpClient myclient = new SmtpClient (); MyClient. 
 Host = "smtp.163.com"; SMTP Service port myclient.
 Port = 25; Verify the login myclient. Credentials = new NetworkCredential ("", "* * *");/"@" Enter a valid message name, "*" Enter a valid password myclient.
 Send (MyMail); }

3, the effect is as follows

3.1, the following figure fill in the items, click to send mail


3.2, 163 in the mailbox

3.3, QQ mailbox

The above is the entire content of this article, I hope that you learn C # program to help.

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.