Sending mail (following the SMTP protocol is a Simple mail-sending protocol)

Source: Internet
Author: User
Tags mailmessage smtpclient

Handlesendemail.aspx logic

protected void Page_Load (Object Sender,eventargs e)

{

foreach (var item in Request.Form.Keys)

{

if (item. ToString (). Startswidth ("Txtmail"))

{

String Mail=request.form[item. ToString ()];

Setting up SMTP servers and ports

SmtpClient smtpclient=new smtpclient ("[Email protected]", 25);

Set the user name and password to log on to the SMTP service when sending mail

SmtpClient. Credentials=new networkcredentail ("User name", "password");

MailMessage mailmessage=new MailMessage ();

Set Message subject

mailmessage.subject= "Theme";

mailmessage.body= "content";//Content

Mailmessage.form=new mailaddress ("Sender's email address");//Sender Address

MAILMESSAGE.TO.ADD (email);//Recipient

        

MAILMESSAGE.CC.ADD ("cc person e-mail address");//Set CC person address

Attachment attachfile=new Attachment (@ "attachment absolute path");//Accessories

MAILMESSAGE.ATTACHMENTS.ADD (Attachfile);

Smtpclient.send (MailMessage);//Execute Send command

}

}

}

Sending mail (following the SMTP protocol is a Simple mail-sending protocol)

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.