Self-study "1. Email the website

Source: Internet
Author: User
Tags mailmessage smtpclient

<System.Net>    <mailsettings>      <SMTPDeliverymethod= "Network" from= "Lai hai Fei Xia Garments Co., Ltd. &lt; [Email protected]&gt;]>        <NetworkHost= "Smtp.163.com"UserName= "[email protected]"Password="****" />              </SMTP>    </mailsettings>  </System.Net>

Above is the configuration file.

 protected voidButton1_Click (Objectsender, EventArgs e) {            if(page.isvalid) {stringFileName = Server.MapPath ("~/app_data/contactform.txt"); stringMailbody =File.readalltext (fileName); Mailbody= Mailbody.replace ("# #name # #", TextBox1.Text); Mailbody= Mailbody.replace ("# #email # #", TextBox2.Text); Mailbody= Mailbody.replace ("# #phone # #", TextBox3.Text); Mailbody= Mailbody.replace ("# #comments # #", Textbox4.text); Try                {                    //Send yourself a letterMailMessage mail =NewMailMessage (); Mail. from=NewMailAddress ("[email protected]","Lihai Garments Co., Ltd."); Mail. To.add (NewMailAddress ("[email protected]","SQ")); Mail. Subject="from Lihai Clothing official website"; Mail. Body=Mailbody; Mail. Bodyencoding=System.Text.Encoding.Default; //send a letter to the customerMail. To.add (Newmailaddress (TextBox2.Text)); SmtpClient Client=NewSmtpClient (); Client.                    Send (mail); Response.Write ("<script>alert (' send Success ');</script>"); }                Catch(Exception ex) {Response.Write ("<script>alert ('"+ ex. Message +"');</script>"); }                            }                   }

Then the button is implemented.

Darling # #name # #您好! I'm glad to see the message on our official website! Name: # #name # #邮箱: # #email # #电话: # #phone # #留言: # #comments # #我们收到邮件会及时看的哦 ~ need to reply to the first time to reply to you ~ If you are particularly anxious, and did not receive my reply, Can directly call my mobile 132****7727 (Chen Manager) Thank the Pro patronage, I wish you a happy life! The money is wide in! I'm going to do it! 

Finally, a txt text file.

That's OK! haha ^_^

Self-study "1. Email the website

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.