Send mail in Asp.net

Source: Internet
Author: User

Most emails need to be verified. I will write this article.ArticleI hope it will help you with your development projects and give me some comments.

Reference jmail to the project and add the jmail namespace. Here I will reference the messageclass class of the jmail package.

Logging attribute: whether to use logs

Silent attribute: If set to true, jmail will not throw an exception. jmail. Send () will return true or false Based on the operation results

Mailserverusername property: the user name of the sender, such as: abcdef@163.com;

Mailserverpassword attribute: the sender's password

From attribute: sender

Subject attribute: topic

Addattachment () method: append a file

Body attribute: Body of the email.

The following is a complete example:

Public bool Sendmail ()

{

Messageclass email = new messageclass ();

Email. Logging = true;

Email. Silent = true;

Email. mailserverusername = "abcdef@163.com ";

Email. mailserverpassword = "124 ";

Email. From = "abcdef@163.com ";

Email. Subject = "jmail ";

Email. addattachment ("C: \ test. xml", true ,"");

Email. Body = "test jmail send mail ";

Email. addrecipient ("abcdef@163.com", "ABC", null );

Return email. Send ("mail.163.com", false)

}

Author: Pan min

E-mail: jspanmin@jcc-net.com

MSN: jspanmin@163.com

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.