Write code in C # to send mail

Source: Internet
Author: User
Send mail the System.Web.Mail namespace in the. Net Framework provides a class smtpmail for sending e-mail messages, the following is the code for which I send the message:

MailMessage mm=new MailMessage ();

Mm. From= "Lixun007@163.net";
Mm. To= "Bill@Microsoft.com";
Mm. Subject= "received a reply";
Mm. Body= "Why the server properties of the SMTP class do not provide password Authentication";
Mm. Attachments.Add (New MailAttachment ("C:\\Test.txt"));
Attachments implement IList interface, you can add multiple attachments

Smtpmail.smtpserver= "webmail.careland.com.cn";
Set up SMTP server to send mail, no login method for server requiring authentication currently available
For example, 163.net,163.com, I am currently my company's SMTP server
See if there's a better way for everyone.
Smtpmail.send (mm);

MessageBox.Show ("OK");
Test pass on the Win2000




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.