Implementation of the C # send mail feature

Source: Internet
Author: User

The main is to record the following methods, easy to find in the future;

 Public stringGetsendemail (string  from,stringTo,stringSmtpstringPasswordstringSubjectstringbody) {            Try{logrecord.write (NULL,"From :"+ from+"; To:"+ to +"; SMTP:"+ SMTP +";p Assword:"+ Password +"; Subject:"+subject); Logrecord.write (NULL,"the body parameter is:"+body); varBodyarr = body. Split ('|'); if(Bodyarr.length! = One) {Logrecord.write (NULL,"Give"+ to +"E -mail status: Parameter data is not correct"); return "the data for the body parameter is not correct"; }                varBodyall =@"<div class= ' main ' > <p class= ' tx_center ' ><span>xx Group interview notice </span></p> <p>"+ bodyarr[0] +@"Hello! Thank you for your interest in our company! Your resume has been through our preliminary screening, we are inviting you to come to our company to attend the interview. </p> <p> Your job interview is: <span class= ' Color_r ' >"+ bodyarr[1] +@"</span></p> <p> Your interview time is: <span class= ' Color_r ' >"+ bodyarr[2] +@"<span class= ' color_r ' ></span></p> <p> interview considerations: <span class= ' Color_r ' >"+ bodyarr[3] +@"</span><span class= ' color_r ' ></span></p> <p> interview Venue: <span class= ' Color_r ' > "+ bodyarr[4] +@"</span></p> <p> Company address: <span class= ' Color_r ' >"+ bodyarr[5] +@"</span></p> <p> bus route: <span class= ' Color_r ' >"+ bodyarr[6] +@"</span></p> <p><span class= ' color_r ' > Simple map: <br/>"+ bodyarr[7] +@"'/></span></p> <p> please come on time! If you have any questions or changes, please call us at:"+ bodyarr[8] +@", contact person:"+ bodyarr[9] +@"or email description, thank you! </p> <p> Rui Xiang Group profile:</p> <p> Company website:"+ bodyarr[Ten] +@"</p></div>"; Logrecord.write (NULL,"the contents are:"+Bodyall); varMessage =NewMailMessage ( from, to, subject, Bodyall) {bodyencoding=Encoding.default, isbodyhtml=true, Priority=Mailpriority.high}; Logrecord.write (NULL,"before sending"); varClient =Newsmtpclient (SMTP) {usedefaultcredentials=false, Deliverymethod=Smtpdeliverymethod.network, Credentials=NewSystem.Net.NetworkCredential ( from, password)}; Client.                Send (message); Logrecord.write (NULL,"Give"+ to +"E- Mail status: True"); return "true"; }            Catch(Exception e) {logrecord.write (E, e.message); returnE.message; }        }

Implementation of the C # send mail feature

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.