Use of jmail in ASP. NET

Source: Internet
Author: User
Code

Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class mailtest: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
String bodystr = "";
Bodystr = "one test email ";

Jmail. Message jmail = new jmail. Message ();

// Datetime T = datetime. now;
String subject = "one test email ";
String fromemail = "12345@qq.com ";
String toemail = "ysclc@163.com ";
// Silent attribute: If set to true, jmail will not throw an exception error. jmail. Send () will return true or false Based on the operation results
Jmail. Silent = true;
// Logs created by jmail, provided that the loging attribute is set to true
Jmail. Logging = true;
// Character set. The default value is "US-ASCII"
Jmail. charset = "gb2312 ";
// Contentype of a letter. The default value is "text/plain"): If you send an email in HTML format, change it to "text/html.
Jmail. contenttype = "text/html ";
// Add recipient
Jmail. addrecipient (toemail ,"","");
Jmail. From = fromemail;
// Sender's email user name
Jmail. mailserverusername = "12345 ";
// Sender's email password
Jmail. mailserverpassword = "password"; // QQ Password
// Set the mail title
Jmail. Subject = subject;
// Add attachments to the email. (If there are multiple attachments, you can add jmail. addattachment ("C: \ test.jpg", true, null. [Note]: add an attachment to delete the above jmail. contenttype = "text/html. Otherwise, garbled characters will appear in the email.
// Jmail. addattachment ("C: \ test.jpg", true, null );
// Email content
Jmail. Body = bodystr;
// Jmail sending Method
If (jmail. Send ("smtp.qq.com", false ))
{
Response. Write ("OK ");
}
Else
{
Response. Write ("no ");
}
Jmail. Close ();

}
}

The above code is a case

Procedure

  1. Download jmail. dll (click to download)
  2. Register the jmail component locally (place jmail. dll in the System32 folder on the system disk, and run cmd to enter regsvr32 jmail. dll)
  3. Vs adds a reference to jmail. dll.
  4. Run the code above to test the application. You can write your own class as needed.
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.