C # attachments can be sent by sending emails,

Source: Internet
Author: User
Tags add time email account mailmessage smtpclient

C # attachments can be sent by sending emails,

Using System; using System. collections. generic; using System. linq; using System. web; using System. net. mail; namespace Ajax. email {public class GetMail {// MailAddress ds = new MailAddress ("1738819932@qq.com"); // Send (ds, "674580075@qq.com", "subject", "content ", "attachment name"); public GetMail () {}/// <summary> /// send email /// </summary> /// <param name = "MessageFrom"> sender's email address </param>/ // <param name = "MessageTo"> recipient's email address </Param> /// <param name = "MessageSubject"> Email Subject </param> /// <param name = "MessageBody"> email content </param> // /<param name = "SUpFile"> attachments </param> // <returns> </returns> public bool Send (MailAddress MessageFrom, string MessageTo, string MessageSubject, string MessageBody, string SUpFile) {MailMessage message = new MailMessage (); message. from = MessageFrom; message. to. add (MessageTo); // the recipient's email address can be multiple to achieve mass mess Age. Subject = MessageSubject; message. Body = MessageBody; if (SUpFile! = "") {SUpFile = Server. MapPath ("~ /Send an email/Upfile/"+ SUpFile); // obtain the Attachment at the local address // convert the file to Attachments Attachment data = new Attachment (SUpFile, MediaTypeNames. application. octet); // Add time stamp information for the file. contentDisposition disposition = data. contentDisposition; disposition. creationDate = System. IO. file. getCreationTime (SUpFile); disposition. modificationDate = System. IO. file. getLastWriteTime (SUpFile); disposition. readDate = System. IO. file. getLastAccessTime (SUpFile); message. attachments. add (data); System. net. mime. contentType ctype = new System. net. mime. contentType ();} message. isBodyHtml = true; // whether the message is in html format. priority = MailPriority. normal; // the priority of the sent mail. SmtpClient SC = new SmtpClient (); SC. host = "smtp.qq.com"; // specify the server address or IP address of the email. port = 25; // specify the sending Port SC. credentials = new System. net. networkCredential ("Send email account", "account password"); // specify try {SC. send (message); // Send the email} catch {return false;} return true ;}}}

 


Symbol in C Language <Yes

Left shift operator (<)

Removes all the binary bits of an operation object from the left and adds 0 to the right ).

For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,

Move 1 to the left and then a = a * 2;

If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)

Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.

The operand shifts one digit to the right, which is equivalent to dividing the number by 2.

For example, a = a> 2 shifts the binary bit of a two places to the right,

0 or 1 to see whether the number is positive or negative.

Symbol in C Language <Yes

Left shift operator (<)

Removes all the binary bits of an operation object from the left and adds 0 to the right ).

For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,

Move 1 to the left and then a = a * 2;

If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)

Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.

The operand shifts one digit to the right, which is equivalent to dividing the number by 2.

For example, a = a> 2 shifts the binary bit of a two places to the right,

0 or 1 to see whether the number is positive or negative.

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.